Search in Rotated Sorted Array

An array sorted in ascending order is rotated at an unknown pivot. Given the rotated array and a target, return the index if found; otherwise return -1.

Examples

Example 1:

Input:

nums = [4,5,6,7,0,1,2]
target = 0

Output:

4
Loading...
Search in Rotated Sorted Array - Binary Search