Binary Tree Level Order Traversal
Given the root of a binary tree, return its level order traversal: a list of levels, where each level is the list of node values from left to right at that depth.
Open official problem prompt ↗Produce the node values grouped into the horizontal rows of the tree, top to bottom, left to right.
Like reading a corporate org chart one management tier at a time: everyone at the same level before descending to their reports.
- Input
- root = [3, 9, 20, null, null, 15, 7]
- Output
- [[3], [9, 20], [15, 7]]
- Why
- Level 0 is [3], level 1 is [9, 20], and level 2 is [15, 7], each read left to right.
The number of nodes is in the range [0, 2000]-1000 <= Node.val <= 1000