day16
思路:跟上一题类似。
我这里没有想到数组的处理,傻了一下。。。
class Solution {
public:
int maxDepth(Node* root) {
if(root == 0) return 0;
int depth = 0;
for(auto c : root->children)
{
depth = max(depth,maxDepth(c));
}
return depth + 1;
}
};