Problem
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.
Example
We should return its max depth, which is 3.
Solution
Method: Depth-first Search
Time Complexity: O(n)
Space Complexity: O(depth of tree)
1 | """ |
Boundary Condition
- What should I return when the input is empty? Level 0 or Level 1?