/** * Note: The returned array must be malloced, assume caller calls free(). */ int* twoSum(int* nums, int numsSize, int target, int* returnSize){ int i,j,key; int *result=NULL; for(i=0;i<numsSize-1;i++) { key = target - nums[i]; for(j=i+1;j<numsSize;j++) { if(key == nums[j]) { result=(int*)malloc(sizeof(int)*2); result[0]=i; result[1]=j; *returnSize = 2; return result; } } } *returnSize = 0; return result; }
标签:numsSize,returned,第一,int,twoSum,assume,NULL From: https://www.cnblogs.com/anitaguangzi/p/16906052.html