Tree bottom view

Please suggest some hint how to approach the problem

Take a hashmap and start a DFS on the tree with root. Now keep an array levels to store the level number of each node. Now take a base value , say x, for root. This base value serves to separate nodes that lie in a different vertical line. Now for left child pass this value as x - 1 and for right x + 1 and for each such value store the max. Level encountered. Now print the corresponding nodes

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.