class Solution {
public:
int maxDepth(TreeNode* root) {
if(root == nullptr)
return 0;
return max(maxDepth(root->left),maxDepth(root->right))+1;
}
};
二叉树的最大深度
最新推荐文章于 2021-09-29 21:58:39 发布
class Solution {
public:
int maxDepth(TreeNode* root) {
if(root == nullptr)
return 0;
return max(maxDepth(root->left),maxDepth(root->right))+1;
}
};