class Solution
{
public
int maxDepth(TreeNode root
) {
return recurr(root
);
}
int recurr(TreeNode root
){
if(root
==null
) return 0;
int l
= recurr(root
.left
)+1;
int r
= recurr(root
.right
)+1;
return Math
.max(l
,r
);
}
}
转载请注明原文地址:https://tech.qufami.com/read-23824.html