Binary Tree Vertical Order Traversal
Problem Return the vertical order traversal of a binary tree: group nodes by their horizontal column (root is column 0, a left child is column − 1, a right child is column + 1), listing columns left to right and, within a column, top to bottom.
Input / Output
- Input: root of a binary tree.
- Output: list of columns, each a list of node values top-to-bottom.
Constraints
- 0 ≤ nodes ≤ 100.
- Maintain stable top-to-bottom (and left-to-right within a cell) order.
Example
- Input [3,9,20,null,null,15,7] → [[9],[3,15],[20],[7]].
added …