I don't know why my code always got running error,but it worked on VS2012


  • 0
    R
    int *twoSum( int numbers[], int n, int target ){
    int i, j;
    
    for( i = 0; i < n; i++ ){
    	for( j = i + 1; j < n; j++ ){
    		if( ((numbers[i] + numbers[j]) == target)
    			&& (numbers[i] < numbers[j]) ){
    			printf("index1 = %d, index2 = %d\n",i+1, j+1);
    			break;
    		}
    	}
    }
    return 0;
    

    }


  • 0
    X

    i think it's time exceed


  • 0
    Q

    Your solution is too slow. You need O(n)


Log in to reply
 

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