The problem. Given the root of a binary tree, return its values level by level, from top to bottom, and left to right within each level — as a list of lists, one list per level.
Input: root = [3, 9, 20, null, null, 15, 7]
Output: [[3], [9, 20], [15, 7]]
Input: root = [1] Output: [[1]]
Input: root = [] Output: []Preorder, inorder and postorder all go deep first, so they jump between levels. Here we must finish a level before starting the next — this is breadth-first order.
Free account
Sign up to read the rest of this lesson: 6 more sections, 2 drawings, a dry-run simulator and code in JavaScript, Python, Java and C++.
Still to come