combinations of nodes adding up to a sum


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 -


I'm a .NET, PHP, Python, and Javascript developer. Also Project Manager, Scrum Master, and Juilliard trained violist. You cannot connect with me on Facebook, Twitter, or LinkedIn so don't ask.