Back to DSA

Binary Tree Level Order Traversal

medium
Acceptance: 55%
Binary Tree

Perform a breadth-first traversal of a binary tree and return the node values grouped by depth level. Each level's values should be listed from left to right.

Examples

Example 1:
Input:root = [10,5,15,3,7,null,20]
Output:[[10],[5,15],[3,7,20]]
Example 2:
Input:root = [42]
Output:[[42]]

Hints

00:00
1234567