Given a rotated sorted array of unique integers and a target, return the index of target, or -1 if not found. Must run in O(log n).
Binary search with rotation handling: at each step determine which half is sorted, then check if target falls in that sorted half.
- If nums[mid]==target return mid.
- If left half [lo..mid] is sorted (nums[lo]<=nums[mid]):
- If target in [nums[lo], nums[mid]), search left; else search right.
- Else right half [mid..hi] is sorted:
- If target in (nums[mid], nums[hi]], search right; else search left.
- Time Complexity: O(log N)
- Space Complexity: O(1)