Maximum Depth of N-ary Tree – LeetCode 559
Problem
Description
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.
Answer
Original
Code
1 | /* |
思路
简单的数的DFS遍历。时间复杂度$O(n)$,空间复杂度$O(n)$。
耗时$40$ ms,排名$11.47\%$
Better
思路
还没看到更好的思路。