还是递归

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

    public TreeNode(int val) {
        this.val = val;

    }

}
*/
public class Solution {
    public int TreeDepth(TreeNode root) {
        if (root == null){
              return  0;
          }
//      转化成子问题
          int left = TreeDepth(root.left);
          int right = TreeDepth(root.right);
          int res = Math.max(left+1,right+1);
          return  res;
    }
}