MMeta·DSAE5Onsite – Coding 1
Binary Tree Vertical Order Traversal
Problem
Return the vertical order traversal of a binary tree's nodes (column by column, top to bottom, left to right).
Example
Input: [3,9,20,null,null,15,7]
Output: [[9],[3,15],[20],[7]]
Constraints
- 0 ≤ nodes ≤ 100
Approach
BFS tracking a column index per node; bucket by column. Maintain stable top-to-bottom order.
added 6 days ago