[leetcode]-349. Intersection of Two Arrays(C语言)

Given two arrays, write a function to compute their intersection.

Example:
Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2].

Note:

  • Each element in the result must be unique.
  • The result can be in any order.
/**
 * Return an array of size *returnSize.
 * Note: The returned array must be malloced, assume caller calls free().
 */
int* intersection(int* nums1, int nums1Size, int* nums2, int nums2Size, int* returnSize) {
    int i,j,k,s;
    *returnSize=0;
    int *res;
    res=(int *)calloc(nums1Size,sizeof(int *));
    for(i=0;i

你可能感兴趣的:(LeetCode)