#102
Binary Tree Level Order Traversal
pupil · 525 · lc medium +28 · verified · 72.2% accepted · 16,967 likes · top 81%
Description
Given the root of a binary tree, collect node values level by level from top to bottom, left to right, and return them as a list of lists.
Example 1:
Input: root = [3,9,20,null,null,15,7]
Output: [[3],[9,20],[15,7]]
Example 2:
Input: root = [1]
Output: [[1]]
Example 3:
Input: root = []
Output: []
Code
1
2
3
4
5
6
7
8
9