/*
// Definition for a Node.
class Node {
public int val;
public List<Node> children;
public Node() {}
public Node(int _val,List<Node> _children) {
val = _val;
children = _children;
}
};
*/
class Solution {
public int maxDepth(Node root) {
if(root==null)
return 0;
else
{
int num_children = root.children.size();//重要!
int i,max=0;
if(num_children>0)
{
for(i=1,max=maxDepth(root.children.get(0));i<num_children;i++)
if(maxDepth(root.children.get(i))>max)//c语言直接用array[i],java需要用.get(i)方法获取成员
max=maxDepth(root.children.get(i));
}
return max+1;
}
}
}