Back to course home
0% completed
Maximum Depth of N-ary Tree (easy)
Problem Statement
Given a root
of the n-ary tree, return the maximum depth of the tree.
The maximum depth refers to the longest path from the root node to any leaf node.
Nary-Tree input serialization is represented in their level order traversal, each group of children is separated by the null value.
Examples
Example 1:
- Input: root =
[1,null,2,3,4,null,5]
- Expected Output:
3
- Justification: The path from the root node
1
to the farthest leaf node5
goes through nodes1 -> 2 -> 5
, making the depth3
.
Example 2:
- Input: root =
.....
.....
.....
Like the course? Get enrolled and start learning!
Table of Contents
Contents are not accessible
Contents are not accessible
Contents are not accessible
Contents are not accessible
Contents are not accessible