赞
踩
https://leetcode-cn.com/problems/two-sum/
/** * Note: The returned array must be malloced, assume caller calls free(). */ int* twoSum(int* nums, int numsSize, int target, int* returnSize){ int *ans = (int *)malloc(sizeof(int)*2); for(int i = 0;i<numsSize-1;i++){ for(int j = i+1;j<numsSize;j++){ if(i == j){ continue; } if(nums[i]+nums[j] == target){ ans[0] = i; ans[1] = j; *returnSize = 2; return ans; } } } *returnSize = 0; return ans; }
待补充:参考
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。