diff --git a/src/167.c b/src/167.c new file mode 100644 index 0000000..4ff1b21 --- /dev/null +++ b/src/167.c @@ -0,0 +1,28 @@ +/** + * Return an array of size *returnSize containing the 1-based indices of two numbers + * that add up to the target. + * Note: The returned array must be malloced, assume caller calls free(). + */ +#include +int* twoSum(int* numbers, int numbersSize, int target, int* returnSize) { + *returnSize = 2; + int* output = (int*)malloc(2 * sizeof(int)); + + int left =0; + int right = numbersSize-1; + while(left