public class Solution {
public int TreeDepth(TreeNode root) {
return root == null ? 0 : Math.max(TreeDepth(root.left), TreeDepth(root.right)) + 1;
}
} 递归,一行。

public class Solution {
public int TreeDepth(TreeNode root) {
return root == null ? 0 : Math.max(TreeDepth(root.left), TreeDepth(root.right)) + 1;
}
} 递归,一行。