TreesExplained
Vertical Order Traversal
Group nodes by horizontal distance from the root.
Time
O(n log n)
Extra space
O(n)
Use it for
Column-wise views.
Group nodes by horizontal distance from the root.
Time
O(n log n)
Extra space
O(n)
Use it for
Column-wise views.