Grokking the Coding Interview: Patterns for Coding Questions
Vote

0% completed

​

Solution: N-ary Tree Level Order Traversal

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!
Aleksa Rajkovic

Aleksa Rajkovic

· 7 months ago

Please consider updating it so it supports both serialization and deserialization of N-Ary Tree Level Order.

Show 1 reply
Vladimir Surcov

Vladimir Surcov

· a year ago

Task tell us to contstruct tree from array with null but in test data we get tree already

Show 2 replies

Reading Progress

0%


Vote for new content