From CareerCup.com.
Find all combinations of 2 nodes which add up to a particular sum. Must have time complexity of O(n).
My solution was O(nlog n), needed a hint to get the idea of using two simultaneous traversals (one in order, one reverse) to find all the combinations in O(n).
Leave a comment -