Medium · Binary Search
Search in Rotated Sorted Array
Given an array of distinct integers that was sorted in ascending order and then rotated at an unknown pivot, and a target value, return the index of the target, or -1 if it is not in the array.
Examples
Example 1
[4,5,6,7,0,1,2], t=0Output: index 4
Example 2
[4,5,6,7,0,1,2], t=3Output: -1 (absent)
Rebuild it in the studio
Open every published interview problem, solution, scene, and memory room free, with no account.