Dashboard
LC #102

Binary Tree Level Order Traversal

Pattern · ?AmazonGoogleMetaMicrosoftBloomberg

Problem

Return the level-order (BFS) traversal of a binary tree as a list of lists.

Constraints

  • 0 ≤ n ≤ 2000
  • -1000 ≤ Node.val ≤ 1000

Example

Input
root = [3, 9, 20, null, null, 15, 7]
Output
[[3], [9, 20], [15, 7]]
Why
Level 0: [3], Level 1: [9,20], Level 2: [15,7]

Spot the pattern

Which pattern cracks it?

Hints

One at a time
Solve on LeetCode ↗