Closed Juro221 closed 3 years ago
We simply iterate through an array of size N. If X-arr[i] is not in unordered set we insert arr[i] to set and if we find some element in set with this approach, it means that we found 2 elements which sum is X. Time complexity : O(n)
We simply iterate through an array of size N. If X-arr[i] is not in unordered set we insert arr[i] to set and if we find some element in set with this approach, it means that we found 2 elements which sum is X. Time complexity : O(n)