Minimum Right Rotations to Strictly Descending
Problem statement
Return the minimum number of cyclic right rotations that makes values strictly descending. Return 0 when it already qualifies and -1 when no rotation qualifies.
Function
rightRotationsToDescending(values: int[]) → intExamples
Example 1
values = [4,3,2,1,5]return = 1One right rotation moves five to the front.
Example 2
values = [5,4,3]return = 0A qualifying array needs zero rotations.
Constraints
0 <= values.length <= 100000-1000000000 <= values[i] <= 1000000000