18 lines
474 B
C
18 lines
474 B
C
#include <stdlib.h>
|
|
#include "lib.h"
|
|
|
|
int* twoSum(int* nums, int numsSize, int target, int* returnSize) {
|
|
for (int i=0; i<numsSize-1; i++) {
|
|
for (int j=i+1; j<numsSize; j++) {
|
|
if (nums[i] + nums[j] == target) {
|
|
int* res = malloc(2 * sizeof(int));
|
|
res[0] = i;
|
|
res[1] = j;
|
|
*returnSize = 2;
|
|
return res;
|
|
}
|
|
}
|
|
}
|
|
*returnSize = 0;
|
|
return NULL;
|
|
}
|