Runtime beats 100.00% of C submissions


  • 0
    C

    /**

    • Note: The returned array must be malloced, assume caller calls free().
      /
      int
      twoSum(int* nums, int numsSize, int target) {
      int* ret = (int*)malloc(2 * sizeof(int));
      for (int i = 0; i < numsSize - 1; i++)
      {
      for (int j = i + 1; j < numsSize; j++)
      {
      if (nums[i] + nums[j] == target)
      {
      ret[0] = i;
      ret[1] = j;
      break;
      }
      }
      }
      return ret;
      }

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.