Search a Rotated Array

Search for a given number in a sorted array that has been rotated by some arbitrary number.

Statement

We’re given a sorted integer array, nums and an integer value, target. The array is rotated by some arbitrary number. Search the target in this array. If the target does not exist then return -1.

Example

An original array before rotation is given below:

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