Number of Times a Sorted Array is Rotated
Medium

Problem Statement

Given a sorted array of distinct integers which is rotated at some unknown pivot, find the number of times the array has been rotated. This is equivalent to finding the index of the minimum element in the array.

Examples

1Example 1
Input:
{ "nums": [ 4, 5, 6, 7, 0, 1, 2 ] }
Output:
4
2Example 2
Input:
{ "nums": [ 3, 4, 5, 1, 2 ] }
Output:
3
3Example 3
Input:
{ "nums": [ 11, 13, 15, 17 ] }
Output:
0
Loading...

Sign in to Run Code and Submit