Maximum Binary Tree II LeetCode solution in Java
1class Solution {2public TreeNode insertIntoMaxTree(TreeNode root, int val) {3if (root == null) return new TreeNode(val);4if (val > root.val) {5TreeNode newRoot = new TreeNode(val);6newRoot.left = root;7return newRoot;8}9root.right = insertIntoMaxTree(root.right, val);10return root;11}12}