← 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.