We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Thanks for the small examples to visualize. This help alot.
This problem looks like we need to generate horizontal, depth pair for each node, then group them by horizontal coordinate, and just collect the minimum depth from each group.
Tree : Top View
You are viewing a single comment's thread. Return to all comments →
Thanks for the small examples to visualize. This help alot.
This problem looks like we need to generate horizontal, depth pair for each node, then group them by horizontal coordinate, and just collect the minimum depth from each group.
For problem statement:
1 (0, 0) 2 (1, 1) 5 (2, 2) 6 (3, 3) 3 (1, 3) 4 (2, 4)
1 (0, 0)
2 (1, 1) 3 (1, 3)
5 (2, 2) 4 (2, 4)
6 (3, 3)
solution pass all test cases