A sorted array of unique integers was rotated at an unknown pivot (e.g. [10, 20, 30, 40, 50] becomes [30, 40, 50, 10, 20]). Return the index of the minimum element.
Input
arr: a rotated sorted array of unique integers
Output
The index of the smallest element in arr.
Examples
Example 1
Inputarr = [30, 40, 50, 10, 20]
Output3
Explanation: The minimum is 10 at index 3.
Example 2
Inputarr = [3, 5, 7, 11, 13, 17, 19, 2]
Output7
Constraints
Use binary search and compare against the last element to decide which half contains the minimum.
Runs in O(log n) time.