#107

Binary Tree Level Order Traversal II

pupil · 595 · lc medium +29 · verified · 67.7% accepted · 5,155 likes · top 74%

play →

Description

Given the root of a binary tree, return a bottom-up collection of node values: starting from the deepest level and working up to the root, listing each level's values left to right.

Example 1:

Input: root = [3,9,20,null,null,15,7]
Output: [[15,7],[9,20],[3]]

Example 2:

Input: root = [1]
Output: [[1]]

Example 3:

Input: root = []
Output: []

Code

1
2
3
4
5
6
7
8
9