medium

Binary Tree Level Order Traversal

Given the root of a binary tree, return its node values grouped by depth: one list per level, from the root level downward and left to right within a level.

Constraints
  • 0 ≤ number of nodes ≤ 2000
  • -1000 ≤ node value ≤ 1000
Examples
in: root = [3,9,20,null,null,15,7]
out: [[3],[9,20],[15,7]]

Code it yourself

Solve in
Test execution is not yet available for this exercise.Practice journal →Draft saved in this browser.
Hints:
Which approach applies?

Choose an approach to check your pattern recognition, or reveal the discussion when you need help.