← 返回 meta 的题目列表Binary Tree Vertical Order Traversal
类型:online_judge
Given a binary tree, return the values in vertical column order from left to right.
Definitions:
The root has column coordinate 0.
A left child has its parent's column minus 1; a right child has its parent's column plus 1.
Nodes in the same column are output from top to bottom.
If two nodes have the same row and column, output them in left-to-right tree traversal order.
Input Format
A level-order serialized tree, using null for missing nodes.
Output Format
Print a two-dimensional array, one array per column from leftmost to rightmost.
Example
Input
[3,9,20,null,null,15,7]
Output
[[9],[3,15],[20],[7]]
Constraints
0 <= n <= 10^4.
Example
Input
[3,9,20,null,null,15,7]
Output
[[9], [3, 15], [20], [7]]