FastPrepSearch in a Bitonic Array

Search in a Bitonic Array

Bloomberg LP logoBloomberg LP● MediumNEW GRADPHONE SCREEN
Learn

Problem statement

nums contains distinct values, strictly increasing through one peak and strictly decreasing afterward. Return the index of target, or -1 if absent, in O(log n) time.

Function

searchBitonic(nums: int[], target: int) → int

Examples

Example 1

nums = [1,3,10,14,16,7,6,2]target = 3return = 1

3 occurs on the increasing side.

Constraints

  • 1 <= nums.length <= 10^5.

More Bloomberg LP problems

See Bloomberg LP hiring insights
public int searchBitonic(int[] nums, int target) {
  // Write your code here.
}
nums[1,3,10,14,16,7,6,2]
target3
expected1
Checking account…