leetcode 104:二叉树的最大深度

这个题相对简单  简单递归即可

int maxDepth(TreeNode* root){
    if(root==NULL)
        return 0;
    else
        return std::max(maxDepth(root->left)+1,maxDepth(root->right)+1);
}

猜你喜欢

转载自blog.csdn.net/u013263891/article/details/82874722