/**
public class TreeNode {
int val = 0;
TreeNode left = null;
TreeNode right = null;
public TreeNode(int val) {
this.val = val;
}
}
*/publicclassSolution{publicintTreeDepth(TreeNode root){if(root == null)return0;int nLeft =TreeDepth(root.left);//左子树的深度int nRight =TreeDepth(root.right);//右子树的深度//若无子节点,则返回深度是1return1+ Math.max(nLeft,nRight);}}