0559. Maximum Depth
Easy | Tree + Level-order Traversal | 40 ms (93.70%), 16 MB (46.68%)
Source: LeetCode - Maximum Depth of N-ary Tree GitHub: Solution / Performance
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).
Extension question of Level-order traversal.
While traversing the tree in level order, we need to record the current level (depth).
Last updated