Tell me about a coding and algorithms problem focused on searching, including your approach and complexity.
Implement search(nums, target) for a sorted array of distinct integers that was rotated at an unknown pivot. Return the target's index, or -1 if it is absent, while maintaining logarithmic time. Input is an integer list and target; output is an integer index. Examples: nums = [4,5,6,7,0,1,2], target = 0 returns 4; nums = [4,5,6,7,0,1,2], target = 3 returns -1. Constraints: 1 <= len(nums) <= 5000, values are distinct integers.
def search(nums, target):