Back to course home
0% completed
Solution: Problem Challenge 2: Search in Rotated Array
Problem Statement
Given an array of numbers which is sorted in ascending order and also rotated by some arbitrary number, find if a given ‘key’ is present in it.
Write a function to return the index of the ‘key’ in the rotated array. If the ‘key’ is not present, return -1. You can assume that the given array does not have any duplicates.
Note: You need to solve the problem in O(logn) time complexity.
Example 1:
Input: [10, 15, 1, 3, 8], key = 15
Output: 1
Explanation: '15' is present in the array at index '1'.
Example 2:
.....
.....
.....
Like the course? Get enrolled and start learning!