Here is my code
please check…the function name is bottom_view
Here is my code
please check…the function name is bottom_view
your approach is not completely correct
lets consider this tree
20
/ \
8 22
/ \ / \
5 3 4 25
/ \
10 14
If there are multiple bottom-most nodes for a horizontal distance from root, then print the later one in level traversal. For example, in the below diagram, 3 and 4 are both the bottom-most nodes at horizontal distance 0, we need to print 4.
For the above tree the output should be 5, 10, 4, 14, 25.
but your code output is 5 10 4 22 25
you also have to consider level
see this Reference code for better understanding
Reference Code
can we do it without hashmap?
i don’t know the approach without hashmap
tell me your approach i will check it
i used the approch of finding all the levels of tree horizontally…i.e. from left to right …we start level 1 from left and end that level to the right…I think i have to store the vertical level as well…and check if the vertical level of the stored element in the current array is same as the current elemnet then change the value else not
*vertical level is greater than or equal to the current level then update the value else not
to correctly implement this approach you have to use hashmap 