AlgoExpert Notes
Easy Solution 1: HashMap put all numbers x into HashMap<Integer,Boolean> O(n) traversal array to find if y in the HashMap (y=tragetSum-x) O(n) Time complexity: O(n) Space complexity: O(n) Solution 2: Two pointers Sort the arrray. O(nLogn) use Left and Right pointer shrinking the sum to targetSum. O(n) Time complexity: O(n Log n)