0429. Level Order Traversal
Medium | Tree + Recursion / Stack | 32 ms (98.53%), 16.3 MB (96.69%)
Last updated
Was this helpful?
Medium | Tree + Recursion / Stack | 32 ms (98.53%), 16.3 MB (96.69%)
Last updated
Was this helpful?
Source: GitHub:
Given an n-ary tree, return the level order traversal of its nodes' values.
Nary-Tree input serialization is represented in their level order traversal, each group of children is separated by the null value (See examples).
Then, based on the different levels in each recursion, we append the node's value to different lists.