← All problems
The tree, level by level
Problem
Given the root of a binary tree, return its values level by level: a list of lists, where list k holds the values at depth k from left to right.
Examples
Input: [3, 9, 20, null, null, 15, 7]
Output: [[3], [9, 20], [15, 7]]
Hints
Try it first. Every hint reveals a bit more.