Search in Rotated Sorted Array

Given a sorted array that has been rotated at an unknown pivot, return the index of target if it exists. If it does not exist, return -1.

The array contains distinct values, so each target can appear at most once. The goal is to do better than a linear scan by using the structure of the rotation.

Examples
Input: [[4,5,6,7,0,1,2],0]
Output: 4
Hints
Related Problems

Search in Rotated Sorted Array

Given a sorted array that has been rotated at an unknown pivot, return the index of `target` if it exists. If it does not exist, return `-1`.