freshman need help


  • 0
    N
    int* twoSum(int* nums, int numsSize, int target) {
      int head = 0;
      int tail = numsSize -1;
      int output[2];
      for (int i = 0; i < numsSize; i++) {
        int continue_flag = 0;
        int break_flag = 0;
        int head = i;
        tail = numsSize - 1;
        while (tail > head) {
          if (nums[head] + nums[tail] > target) {
            tail --;
          } else if (nums[head] + nums[tail] < target) {
            output[0] = -1;
            output[1] = -1;
            continue_flag = 1;
            break;
          } else {
            output[0] = head;
            output[1] = tail;
            break_flag = 1;
            break;
          }
        }
        if (continue_flag) {
          continue;
        }
        if (break_flag) {
          break;
        }
      }
      return output;
    }
    

    hi, everyone.
    i am a freshman here, i think my code is ok for the testcase when ran in my pc, but can't get results in leetcode. i cant think out what's wrong with it, can anyone help me? i know it maybe really simple, thanks you in advance.


Log in to reply
 

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