Facebook | Phone | Two sum in Binary Tree
Anonymous User
3406

Given a binary tree and an integer K, return two nodes which are at different level and their sum is equal to K.

Constraints :

  1. Tree can have duplicate values.
  2. Incase more than one pair is available in the tree, then return any of the pair.

I gave a solution based on DLL and HashMap, but it is not very optimised. This led to rejection :(

Please let me know your thoughts on this.

Comments (19)