
class Solution {
public:
int maxDepth(TreeNode* root) {
if(root==nullptr)return 0;
return max(maxDepth(root->left),maxDepth(root->right))+1;
}
};
原创
leetcode104. 二叉树的最大深度
本文采用 CC BY-NC-SA 4.0 许可协议,转载请注明出处。