← 返回 meta 的题目列表Vertical Order Traversal of a Binary Tree
类型:online_judge
Given a binary tree, print the nodes' values in column order from left to right, top to bottom.
Example:
Consider the following binary tree:
3
/ \
9 20
/ \
15 7
Output:
[[9],[3,15],[20],[7]]
Constraints:
The number of nodes does not exceed 1000.
Node values are integers.
Write a function verticalOrderTraversal to achieve the above functionality.
Example
Input
3
9 20
null null 15 7