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
This is in Java : This even removes the possible duplicates.. Runtime - O(n^2)
O(n^2)
private static int[] intArray = {15,5,10,20,25,30}; private static int sum = 35; private static void algorithm() { Map intMap = new Hashtable(); for (int i=0; i