← 返回 meta 的题目列表Binary Tree Vertical Order Traversal
类型:online_judge
Given the root of a binary tree, return its vertical order traversal.
Definitions:
The root has column index 0.
Left child column = parent column -1; right child column = parent column +1.
Output columns from left to right (in increasing column index).
Within the same column, output nodes from top to bottom; if multiple nodes share the same row and column, output them from left to right.
Return a 2D list ans where each inner list contains values in one column from leftmost to rightmost.
Constraints:
Number of nodes n: 0 <= n <= 10^4
Example
Input (level-order, null for empty):
[3,9,20,null,null,15,7]
Output:
[[9],[3,15],[20],[7]]
Example
Input
[3,9,20,null,null,15,7]
Output
[[9],[3,15],[20],[7]]