题目:https://leetcode-cn.com/problems/maximum-depth-of-binary-tree/submissions/
答案:
二叉树遍历递归
public int maxDepth(TreeNode root) {
if(root==null) {
return 0;
}else {
int heightLeft = 1+maxDepth(root.left);
int heightRight = 1+maxDepth(root.right);
return Math.max(heightLeft,heightRight);
}
}