Time limit exceeded. I'm new to this site. Please help me.


  • 0
    V

    /**

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

  • 0
    A

    If you don't indent your code, it will be really difficult for anyone to read and help you with the code.


Log in to reply
 

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