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

Method findInMountainArray

java/1095-find-in-mountain-array.java:11–17  ·  view source on GitHub ↗
(int target, MountainArray mountainArr)

Source from the content-addressed store, hash-verified

9
10class Solution {
11 public int findInMountainArray(int target, MountainArray mountainArr) {
12 int maxIndex = findMax(mountainArr);
13 int leftResult = binarySearchLeft(mountainArr, target, maxIndex);
14 int rightResult = binarySearchRight(mountainArr, target, maxIndex);
15
16 return (leftResult == -1 && rightResult == -1) ? -1 : leftResult == -1 ? rightResult : leftResult;
17 }
18
19 public int findMax(MountainArray array) {
20 int left = 0;

Callers

nothing calls this directly

Calls 3

findMaxMethod · 0.95
binarySearchLeftMethod · 0.95
binarySearchRightMethod · 0.95

Tested by

no test coverage detected