二叉树的深度

穿过雾的阴霾 / 2023-05-07 / 原文

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