← 返回 bloomberg 的题目列表Binary Tree Vertical Order Traversal
类型:online_judge
Problem
Given the root of a binary tree, return its vertical order traversal.
Definition:
Root has column 0
Left child column = parent column - 1
Right child column = parent column + 1
Output requirements:
Columns from leftmost to rightmost
Within the same column, order nodes from top to bottom (BFS encounter order)
Input format (suggested)
Level-order array with null for missing nodes.
Constraints
Number of nodes N: 0 <= N <= 2e5
Example
Input: [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]]