Ezvor

314. Binary Tree Vertical Order Traversal

MediumHash Table Preparing judge… LeetCode
Hash TableTreeDepth-First SearchBreadth-First SearchSortingBinary Tree

Hints

Hint 1
Do BFS from the root. Let the root be at column 0. In the BFS, keep in the queue the node and its column.
Hint 2
When you traverse a node, store its value in the column index. For example, the root's value should be stored at index 0.
Hint 3
If the node has a left node, it column should be col - 1. Similarly, if the node has a right node, its column should be col + 1.
Hint 4
At the end, check the minimum and maximum col and output their values.