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

Method binarySearchRight

java/1095-find-in-mountain-array.java:52–68  ·  view source on GitHub ↗
(MountainArray array, int target, int left)

Source from the content-addressed store, hash-verified

50 }
51
52 public int binarySearchRight(MountainArray array, int target, int left) {
53 int right = array.length() - 1;
54
55 while (left <= right) {
56 int mid = left + (right - left)/2;
57 int midValue = array.get(mid);
58
59 if (midValue < target) {
60 right = mid - 1;
61 } else if (midValue > target) {
62 left = mid + 1;
63 } else {
64 return mid;
65 }
66 }
67 return -1;
68 }
69}

Callers 1

findInMountainArrayMethod · 0.95

Calls 1

getMethod · 0.45

Tested by

no test coverage detected