diff --git a/leetcode/src/.DS_Store b/leetcode/src/.DS_Store new file mode 100644 index 0000000000..222045d5aa Binary files /dev/null and b/leetcode/src/.DS_Store differ diff --git a/leetcode/src/167.c b/leetcode/src/167.c new file mode 100644 index 0000000000..4ff1b2174e --- /dev/null +++ b/leetcode/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