-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
Description
/*
// Definition for a Node.
class Node {
public:
int val;
vector<Node*> children;
Node() {}
Node(int _val, vector<Node*> _children) {
val = _val;
children = _children;
}
};
*/
class Solution {
public:
int maxDepth(Node* root) {
if(root == nullptr) return 0;
int r = 0;
for(auto node : root->children){
r = max(maxDepth(node), r);
}
return r + 1;
}
};