Search in a Bitonic Array
Hard

Problem Statement

Given a bitonic array and a target key, find if the key is present in the array. Return its index if found, otherwise return -1.

Examples

1Example 1
Input:
{ "arr": [ 1, 3, 8, 12, 4, 2 ], "key": 4 }
Output:
4
2Example 2
Input:
{ "arr": [ 5, 10, 20, 15 ], "key": 20 }
Output:
2
3Example 3
Input:
{ "arr": [ 1, 2, 3, 4, 5 ], "key": 3 }
Output:
2
Loading...

Sign in to Run Code and Submit