【leetcode】和为s的两个数字
int* twoSum(int* nums, int numsSize, int target, int* returnSize){
int left = 0;
int right = numsSize - 1;
*returnSize = 2;
int *ret = (int*)malloc(*returnSize * sizeof(int));
while (left < right) {
if (nums[left] + nums[right] == target) {
ret[0] = nums[left];
ret[1] = nums[right];
return ret;
} else if (nums[left] + nums[right] > target) {
right--;
} else {
left++;
}
}
return NULL;
}