The following is a problem taken from leetcode: Two Sum problem, where a specific target value should be achieved from the sum of any 2 elements in the array and the indices of the two elements should be stored in the return array which should be malloced and returned.
I am getting an error as 'ret is redeclared as different kind of symbol'
.
/**
* Note: The returned array must be malloced, assume caller calls free().
*/
int *twoSum(int *nums, int numsSize, int target, int *ret) {
int i, j;
int *ret = (int *)malloc(sizeof(int) * 2);
for (i = 0; i < numsSize; i++) {
for (j = i + 1; j < numsSize; j++) {
if (nums[i] + nums[j] == target) {
ret[0] = i;
ret[1] = j;
}
}
}
return ret;
}