0559. Maximum Depth
Easy | Tree + Level-order Traversal | 40 ms (93.70%), 16 MB (46.68%)
Last updated
Was this helpful?
Easy | Tree + Level-order Traversal | 40 ms (93.70%), 16 MB (46.68%)
Last updated
Was this helpful?
Source: GitHub:
Given a n-ary tree, find its maximum depth.
The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.
Nary-Tree input serialization is represented in their level order traversal, each group of children is separated by the null value (See examples).
While traversing the tree in level order, we need to record the current level (depth).