How can I write an algorithm to check if the sum of any two numbers in an array/list matches a given number with a complexity of nlogn?
nlogn
Step 1 : Sort the array in O(n logn)
Step 2 : Find two indices
0<=i
int i=0,j=n; while(i k) j--; }