Maximum Depth of N-ary Tree
给一个n叉树, 返回最深的depth.
1 2 3 4 5 6 7 8 9 10 11 |
class Solution { public int maxDepth(Node root) { if(root == null) return 0; int res = 0; for(Node n : root.children) { res = Math.max(res, maxDepth(n)); } return res+1; } } |