Could anyone help me??


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

    }


  • 0
    P

    Syntax is wrong for the 2nd if statement . Should be '==' and I think you should be checking for j == 'numsSize-1'.


Log in to reply
 

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