less than 1 minute read

Given a binary tree root return a level order traversal of the node values.

Constraints

  • n ≤ 100,000 where n is the number of nodes in root

https://binarysearch.com/problems/Level-Order-Traversal

Examples

Example 1

Input

  • root =

Output

  • answer = [0, 1, 2, 3]

Example 2

Input

  • root =

Output

  • answer = [0, 5, 9, 1, 3, 4, 2]

Example 3

Input

  • root =

Output

  • answer = [0, 1, 2, 3]

Solution

Leave a comment