//就是左树的深度 和 右树的深度 的最大值加一
public class Solution {
public int TreeDepth(TreeNode root) {
if(root == null) {
return 0;
}
return Math.max(TreeDepth(root.left), TreeDepth(root.right)) + 1;
}
}
//就是左树的深度 和 右树的深度 的最大值加一
public class Solution {
public int TreeDepth(TreeNode root) {
if(root == null) {
return 0;
}
return Math.max(TreeDepth(root.left), TreeDepth(root.right)) + 1;
}
}