题目描述:
代码:
/**
* Definition for a binary tree node.
* public class TreeNode {
* int val;
* TreeNode left;
* TreeNode right;
* TreeNode(int x) { val = x; }
* }
*/
class Solution {
public int maxDepth(TreeNode root) {
if (root==null)return 0;
int n1=this.maxDepth(root.left);
int n2=this.maxDepth(root.right);
return n1>=n2?n1+1:n2+1;
}
}