简单题。顺手就写出来了。
public class Solution { public int maxDepth(TreeNode root) { // Start typing your Java solution below // DO NOT write main() function if (root == null) return 0; if (root.left == null && root.right == null) return 1; int lmax = maxDepth(root.left) + 1; int rmax = maxDepth(root.right) + 1; return Math.max(lmax, rmax); } }