Java, J2EE, SQL, Frameworks, APIs, Exceptions and more..
Wednesday, July 25, 2018
Find a pair of elements from an array whose sum equals to a given number
The best way would be to insert every element into a hashset. Then for every x, we can just look up its complement, T-x.
Overall the Time Complexity of this approach is O(n).
Share to Twitter
Share to Facebook
Share to Pinterest