/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode() {} * TreeNode(int val) { this.val = val; } * TreeNode(int val, TreeNode left, TreeNode right) { * this.val = val; * this.left = left; * this.right = right; * } * } */ class Solution { public TreeNode insertIntoMaxTree(TreeNode root, int val) { if(null == root) return new TreeNode(val); if(val > root.val) { TreeNode n = new TreeNode(val); n.left = root; return n; } root.right = insertIntoMaxTree(root.right,val); return root; } }