(MountainArray array, int target, int right)
| 33 | } |
| 34 | |
| 35 | public int binarySearchLeft(MountainArray array, int target, int right) { |
| 36 | int left = 0; |
| 37 | |
| 38 | while (left<=right) { |
| 39 | int mid = left + (right - left)/2; |
| 40 | int midValue = array.get(mid); |
| 41 | if (midValue < target) { |
| 42 | left = mid + 1; |
| 43 | } else if (midValue > target) { |
| 44 | right = mid - 1; |
| 45 | } else { |
| 46 | return mid; |
| 47 | } |
| 48 | } |
| 49 | return -1; |
| 50 | } |
| 51 | |
| 52 | public int binarySearchRight(MountainArray array, int target, int left) { |
| 53 | int right = array.length() - 1; |
no test coverage detected