Rotation Count in a Rotated Sorted Array

A strictly increasing array of distinct integers was rotated to the right zero or more times. Return the number of rotations. The rotation count is the index…

A strictly increasing array of distinct integers was rotated to the right zero or more times. Return the number of rotations. The rotation count is the index of the smallest value. For example, `[4,5,1,2,3]` was rotated twice, and its minimum value is at index 2.

- `1 <= nums.length <= 10^5` - `-10^5 <= nums[i] <= 10^5` - All values are distinct and form one rotation of a strictly increasing array.

Example 1: input nums = [4,5,6,7,0,1,2]; output 4. The sorted original was [0,1,2,4,5,6,7]. Rotating it right 4 times moves the minimum 0 from index 0 to index 4, so the rotation count is 4.

Example 2: input nums = [11,13,15,17]; output 0. The array is already sorted and therefore has rotation count zero.

Category: Binary Search. Topic: binary-search. Difficulty: Easy. Patterns: binary-search.