Given a rotated sorted array of distinct integers, return the number of times the array has been rotated. The rotation count is equal to the index of the minimum element in the array. The array was originally sorted in ascending order and then rotated clockwise.
Example 1
Input: nums = [15,18,2,3,6,12]
Output: 2
Explanation: The minimum element is 2, which is at index 2. Therefore, the array has been rotated 2 times.
Example 2
Input: nums = [7,9,11,12,5]
Output: 4
Explanation: The minimum element is 5 at index 4, so the array has been rotated 4 times.
Example 3
Input: nums = [1,2,3,4,5]
Output: 0
Explanation: The array is not rotated. The minimum element is at index 0, so rotation count is 0.
Sign in to write, run, and submit your solution against the full test suite.