MCPcopy Index your code
hub / github.com/qiyuangong/leetcode / construct

Method construct

java/654_Maximum_Binary_Tree.java:5–13  ·  view source on GitHub ↗
(int[] nums, int l, int r)

Source from the content-addressed store, hash-verified

3 return construct(nums, 0, nums.length);
4 }
5 public TreeNode construct(int[] nums, int l, int r) {
6 if (l == r)
7 return null;
8 int max_i = max(nums, l, r);
9 TreeNode root = new TreeNode(nums[max_i]);
10 root.left = construct(nums, l, max_i);
11 root.right = construct(nums, max_i + 1, r);
12 return root;
13 }
14 public int max(int[] nums, int l, int r) {
15 int max_i = l;
16 for (int i = l; i < r; i++) {

Callers 1

Calls 1

maxMethod · 0.95

Tested by

no test coverage detected