โ† Trees, Graphs & DP
#4 most askedVery commonMediumTree BFS

Binary Tree Level Order Traversal

New to Tree BFS? Learn it from scratch first
Tree Traversals โ†’
๐Ÿข Asked in real interviews
No reports yet. Were you asked this? Be the first to say where.
I was asked this

Return the node values level by level, left to right.

[3, 9, 20, None, None, 15, 7] โ†’ [[3], [9, 20], [15, 7]]

๐Ÿงช Practice

Write your solution, then press Run tests. Explain your approach out loud as you go.

Python
from collections import deque

def level_order(root):
    pass

Output appears here. Press Run or Ctrl/โŒ˜ + Enter.

Try it first. Struggling for a few minutes is how it sticks.