can you tell me my logic is correct or not one test case fail in tree bottom view printing please update my code with comment
Bottom view of binary tree one test case fail
@bishtmanish786 Consider the case:
20 8 22 5 3 4 25 -1 -1 10 14 -1 -1 -1 -1 -1 -1 -1 -1
Expected Output:
5 10 4 14 25
Your Output:
5 10 4 22 25
With this example, check how you are going wrong with the code or logic.
Or follow this approach:
By maintaining a hashmap for horizontal distance of each node and by the BFS traversal you can solve this problem.
Hope this helps!
@pratyush63 sir
update ->
i have done this problem https://ide.codingblocks.com/s/119779 is it right way to solve it ?