Binary Tree Level Order Traversal
Part of Practice: Levels & BST Rules
Given the root of a binary tree, return its node values grouped by level: a list of lists, where the first inner list holds the root's value, the second holds the values at depth 2 from left to right, and so on down the tree.
The tree has 0 to 2,000 nodes. An empty tree yields an empty list.
Examples
- Input:
- root = [3,9,20,null,null,15,7]
- Output:
- [[3],[9,20],[15,7]]
- Input:
- root = [1]
- Output:
- [[1]]
- Input:
- root = []
- Output:
- []
Hints
One at a time — struggle first, peek second.
Your thinking space — verify on LeetCode, then mark it.