MCPcopy Create free account
hub / github.com/neetcode-gh/leetcode / findMax

Method findMax

java/1095-find-in-mountain-array.java:19–33  ·  view source on GitHub ↗
(MountainArray array)

Source from the content-addressed store, hash-verified

17 }
18
19 public int findMax(MountainArray array) {
20 int left = 0;
21 int right = array.length() - 1;
22
23 while (left<=right) {
24 int mid = left + (right - left)/2;
25 if (array.get(mid) < array.get(mid + 1)) {
26 left = mid + 1;
27 } else {
28 right = mid - 1;
29 }
30 }
31
32 return left;
33 }
34
35 public int binarySearchLeft(MountainArray array, int target, int right) {
36 int left = 0;

Callers 1

findInMountainArrayMethod · 0.95

Calls 1

getMethod · 0.45

Tested by

no test coverage detected