Java Approach.

public TreeNode constructMaximumBinaryTree(int[] nums) { if (nums.length == 0) return null; int maxIdx = 0; for (int idx = 0; idx < nums.length; idx ++) if (nums [idx] > nums [maxIdx]) maxIdx = idx; TreeNode n = new TreeNode (nums [maxIdx]); n.left = constructMaximumBinaryTree (Arrays.copyOfRange(nums, 0, maxIdx)); n.right = constructMaximumBinaryTree (Arrays.copyOfRange(nums, maxIdx + 1, nums.length)); return n; }