很简单,也没啥坑点
class Solution {
public:
int maxDepth(TreeNode* root) {
if(!root) return 0;
int dep = max(maxDepth(root -> left), maxDepth(root -> right)) + 1;
return dep;
}
};
标签:return,dep,int,maxDepth,深度,root,leetcode,二叉树
来源: https://www.cnblogs.com/rookie-acmer/p/15047242.html