From 506073d990c5961a817fc9a6d66ec778ff16831e Mon Sep 17 00:00:00 2001 From: Vaibhav Patidar <78547671+Vaibhav-Patidar@users.noreply.github.com> Date: Sat, 25 Oct 2025 10:15:39 +0530 Subject: [PATCH] Add solution for Problem:167 in C lang --- src/167.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/167.c 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