Java, J2EE, SQL, Frameworks, APIs, Exceptions and more..
Pages
Home
About
Guest Post
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).
Newer Post
Older Post
Home