【leetcode】N叉树的最大深度

 

复制代码
int maxDepth(struct Node* root){
    if(!root) return 0;
    int max = 0;
    for(int i = 0; i < root->numChildren; ++i){
        int temp = maxDepth(root->children[i]);
        max = max > temp ? max : temp;
    }
    return max + 1;
}
复制代码

 

posted @   温暖了寂寞  阅读(165)  评论(0编辑  收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示