Given the root of a binary tree, return its levels as a list of lists, deepest level first and the root's level last. Inside each level keep the nodes in left-to-right order.
Examples
8
/ \
4 13
/ \
12 6
Input: root = build_tree([8, 4, 13, None, None, 12, 6])
Output: [[12, 6], [4, 13], [8]]
Input: root = build_tree([])
Output: []
Constraints
0 <= number of nodes <= 2000-10**4 <= node.val <= 10**4- Target complexity: O(n) time.
Goals
- Group nodes by level with a queue
- Reverse the level order at the end
- Return [] for an empty tree