am not able to understand sample test case
please help
Tree top view problm
Hey Jai, given input for tree is 1 2 3 4 5 6 -1 -1 -1 -1 -1 -1 -1 which will result in a tree like this.
1
/ \
/ \
2 3
/ \ \
/ \ \
4 5 6
now if you view this tree from top you will see the nodes 4 2 1 3 and that’s the answer. So, basically you have to print the nodes from left to right which can be seen if we view the tree from the top.