leecode第一周
思路:如果我们知道了左子树和右子树的深度分别为 l 和 r,那么该二叉树的最大深度即为 max(l,r)+1 class Solution {public: int maxDepth(TreeNode* root) { if (root == nullptr) return 0; return max(maxDepth(root->left), maxDepth(root->right)) + 1; }}; int uniq
原创
2021-05-16 21:47:00 ·
77 阅读 ·
0 评论