← Problems

Binary Tree Level Order Traversal

MEDIUM
Problem⌘ K
Binary TreeBFS

Binary Tree Level Order Traversal

Given the root of a binary tree, return the level order traversal of its node values from left to right, level by level.

Example

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

Constraints

The number of nodes is in the range [0, 2000].-1000 ≤ Node.val ≤ 1000.

Think about

Try a first approach in the editor. Copilot reviews your actual code and asks one focused question when it finds a gap.

solution.c
Test resultsReady
$ Type your approach, then run the sample tests.
LIVE AI REVIEW · WAITING
Start typing or paste your attempt here.