Grokking Tree Coding Patterns for Interviews
Vote

0% completed

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.

Your function receives the root node of an already built tree. The array form above is only how the examples and tests write a tree down; the harness parses it and builds the nodes before calling your code. You do not construct the tree yourself.

Examples

.....

.....

.....

Like the course? Get enrolled and start learning!
J

jsk935

· 2 months ago

The question description is slightly confusing. The input is a Node, NOT an array of the format [1, null, 2, 3, 4, null, 5, 6].

Show 2 replies

Reading Progress

0%


Vote for new content