https://leetcode.com/problems/maximum-depth-of-n-ary-tree/description/
非常简单的题目,连edge case 都没有。思路就是:最大深度 = 孩子的最大深度 + 1
/* // 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 cnt = 0; for (Node* n : root->children) { cnt = max(maxDepth(n), cnt); } return cnt+1; } };