Given a rotated sorted array of distinct integers, implement a function that returns the index of a target value or -1 if it is not present. The solution must run in O(log n) time, so a linear scan is not acceptable.
Constraints
1 <= nums.length <= 10^5
All values in nums are distinct
nums is sorted in ascending order and rotated at an unknown pivot
-10^4 <= nums[i], target <= 10^4
Interviewer
Your question is Search in Rotated Sorted Array. Start with the requirements in the Question tab.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.