Binary Tree Level Order Traversal

Medium · Trees · Tree · BFS · Queue

Problem

Return the values of a binary tree level by level, top to bottom, each level left to right as its own list.

from_level() and to_level() are provided.

Examples

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

Three levels.

Input: root = []
Output: []

Constraints

Approaches

Related problems

Start free on Cariara · Coding problems · System design studio

Starting Python
No results yet.

          
↑↓ move ↵ open esc close

Labs

Loading labs…

Run with your own input

Starting Python

Loading Python…