public class Solution {
public class TreeNode {
int val = 0;
TreeNode left = null;
TreeNode right = null;
public TreeNode(int val) {
this.val = val;
}
public int TreeDepth(TreeNode root) {
if (root==null)
return 0;
int leftdepth = TreeDepth(root.left);
int rightdepth = TreeDepth(root.right);
return (leftdepth>rightdepth)?(leftdepth+1):(rightdepth+1);
}
}
07-21
2294
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)