Search In Rotated Sorted Array
A strictly increasing array was rotated, possibly zero times. Return the zero-based index of target, or -1 if absent, in logarithmic time.
Example 1
nums = [6,8,1,3,4]
target = 33Explanation
3 occurs at index 3 after the rotation boundary.
Example 2
nums = [6,8,1,3,4]
target = 5-1Explanation
5 is absent despite lying between the smallest and largest values.
Example 3
nums = [2]
target = 20Explanation
The sole element matches at index 0.
Constraints
- 1 <= len(nums) <= 5000
- All values are distinct
Function contract
searchArguments: json, jsonSolutionRuns on your device
Loading draft…
Run: 3 examples; Submit: 35 cases, on your device.
[6,8,1,3,4]3