二叉树的深度

class Solution {
public:
    int treeDepth(TreeNode* root) {
        if(!root)   return 0;
        return max(treeDepth(root->left),treeDepth(root->right))+1;
    }
};
posted @ 2023-05-07 17:01  穿过雾的阴霾  阅读(19)  评论(0)    收藏  举报