Back to course home
0% completed
Vote For New Content
N-ary Tree Level Order Traversal (hard)
Problem Statement
Given an n-ary tree, return a list representing the level order traversal of the nodes' values in this tree.
The input tree is serialized in an array format using level order traversal, where the children of each node are grouped together and separated by a null value.
Examples
Example 1
- Input: root =
[1, null, 2, 3, 4, null, 5, 6]
- Expected Output:
[[1], [2, 3, 4], [5, 6]]- Justification: The root node
1is at level 0. Nodes2,3, and4are the children of1and are at level 1. Nodes5and6are the children of `2
- Justification: The root node
.....
.....
.....
Like the course? Get enrolled and start learning!
On this page