Element in Bitonic Array

Let's try to conduct a binary search of a bitonic array. Difficulty Level: Medium

Problem statement

Suppose we are given an integer array, nums, which is guaranteed to be a bitonic array and a target value. It will return the index if the target is found. If not, it will return -1.

Constraints:

  • 3nums.length1053 \leq nums.length \leq 10^5

  • 1nums[i],target1081 \leq nums[i], target \leq 10^8

  • A given array always contains a bitonic point.

  • Array nums always contain distinct elements.

Example 1:

Input: [3, 9, 10, 20, 17, 5, 1], 20    
Output: 3

Example 1:

Input: [5, 6, 7, 8, 9, 10, 3, 2, 1], 30    
Output: -1

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.