主要就是递归思想 , 必须搞懂递归

import java.util.*;

/*
 * public class TreeNode {
 *   int val = 0;
 *   TreeNode left = null;
 *   TreeNode right = null;
 * }
 */

public class Solution {
    /**
     * 
     * @param root TreeNode类 
     * @return int整型
     */
    public int maxDepth (TreeNode root) {
        // write code here
        if(root == null){
            return 0;
        }
      int  leftDepth = maxDepth(root.left);
      int   rightDepth = maxDepth(root.right);
        return Math.max(leftDepth+1,rightDepth+1);

    }
}