Back to problems

N-ary Tree Level Order Traversal

Algorithm · Uber · Medium

Traverse an N-ary Tree by Level This practice task represents an N-ary tree in level-order notation, placing -1 between groups of sibling nodes. For instance, the representation is [1,-1,3,2,4,-1,5,6]. Produce the tree's values in level-order traversal format. Examples Example 1: Input: serialized = [1,-1,3,2,4,-1,5,6] Output: [[1],[3,2,4],[5,6]] The root forms the first level, its children form the second, and the remaining descendants form the third. Constraints 0 <=…

Checking your access…