Binary Tree Level Order Traversal - aloalgo

Binary Tree Level Order Traversal

Medium

You are given the root of a binary tree.

Your task is to compute the level order traversal of its nodes' values, collecting all node values level by level.

Return a single list of numbers

Example 1

Input
5316984
Output
[5, 3, 8, 1, 4, 6, 9]
Explanation:

The level order traversal visits nodes level by level: first 5, then 3 and 8, followed by 1, 4, 6, and 9.

Example 2

Input
None
Output
[]
Explanation:

An empty tree results in an empty list.

Loading...
Input
5316984
Output
[5, 3, 8, 1, 4, 6, 9]

Hello! I am your ✨ AI assistant. I can provide you hints, explanations, give feedback on your code, and more. Just ask me anything related to the problem you're working on!