LeetCode题解之Maximum Depth of N-ary Tree
作者:互联网
1、题目描述
2、问题分析
利用递归fangf
3、代码
1 int maxDepth(Node* root) { 2 int res = maxdep(root); 3 return res; 4 } 5 6 int maxdep(Node *root) 7 { 8 if (root == NULL) 9 return 0; 10 else { 11 int res = 1; 12 for (auto child : root->children) { 13 res = max(res,maxdep(child)+1); 14 } 15 return res; 16 } 17 }
标签:child,return,int,题解,maxdep,Tree,res,ary,root 来源: https://www.cnblogs.com/wangxiaoyong/p/10425445.html