← 返回 meta 的题目列表Binary Tree Vertical Order Traversal
类型:online_judge
Given a binary tree, implement a function to output the tree's vertical order traversal. Each node should be ordered from top to bottom and from left to right. The result should be a list where each sublist represents a vertical level in the tree. Nodes within each vertical level should be ordered from top to bottom. Use breadth-first search algorithm to implement.
Constraints:
The number of tree nodes is in the range [0, 1000].
Each node has a unique value.
Example Input:
Input:
3
/ \
9 20
/ \
15 7
Output: [[9], [3, 15], [20], [7]]
Example
Input
3