A service may receive a sorted sequence of content identifiers after it has been rotated at an unknown position. Given a rotated sorted array of distinct integers and a target value, return the target's index, or -1 if it is not present.
The array was originally sorted in strictly increasing order and rotated between 0 and n - 1 positions. Design an algorithm with O(log n) time complexity.
Implement search_rotated(nums, target):
nums, a list of distinct integers representing the rotated sorted array, and target, an integer to locate.target, or -1 when the target does not occur.def search_rotated(nums, target):