I did it in o(n^2)


  • -1
    R
    #include<stdio.h>
    
    int main()
    {
    	int i,j;
    	int a[]={2,7,11,15};
    	for(i=0;i<4;i++)
    	{
    		for(j=1;j<4;j++)
    		{
    		if(a[i]+a[j]==13)
    		printf("%d %d",i,j);
    		}
    	}
    }
    

Log in to reply
 

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