leetcode

104.二叉树的最大深度

力扣链接

class Solution {
public:
    int maxDepth(TreeNode* root) {
        if (!root) return 0;
        return std::max(maxDepth(root->left), maxDepth(root->right))+1; 
    }
};