思路:递归算法,从上至下计算
class Solution {
private int ans;
public int maxDepth(TreeNode root) {
if(root==null) return 0;
if(root.left==null&&root.right==null) return 1;
return Math.max(maxDepth(root.left),maxDepth(root.right))+1;
}
}