面试必考精华版Leetcode104. 二叉树的最大深度

题目:

面试必考精华版Leetcode104. 二叉树的最大深度_第1张图片


 

代码(首刷自解 day23):

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

你可能感兴趣的:(#,leetcode,---,easy,前端,算法,javascript)