can you please explain how the sample input and output are working for this problem. also please show the tree made from given input.
Doubt in sample input and output
@ritesh2000
Let us consider the sample testcase given in the problem
Input :
1 2 3 4 5 6 -1 -1 -1 -1 -1 -1 -1
Sample Output :
4 2 6 3
We are given the level order input in this problem
Here the tree looks like
1
/ \
2 3
/ \ /
4 5 6
The botttom view of this tree as we can see from left to write would be
4 2 6 3
Note the situation of ambiguity at the third node since 5 from left subtree and 6 from right subtree at present at the same structural position at the same height so we pick the one that was created afterwards , that is , the one from the right subtree.
This problem is solved using Hashing with trees.