Minimum right shifts to sort the array Solution in C
IntuitionApproachComplexity

Time complexity:
O(n)


Space complexity:
O(1)

Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
O(n)

- Space complexity:
O(1)

# Code
```c []
int minimumRightShifts(int* nums, int numsSize) {
    int pivotid = 0, pivotcount = 0;
    for (int i=1;i<numsSize;i++)
    {
        if (nums[i-1] > nums[i])
        {
            pivotid = i;
            pivotcount++;
        }
    }
    if (pivotcount > 1)
        return -1;
    else if (pivotid == 0)
        return 0;
    else
        return (nums[numsSize-1] > nums[0])?-1 : numsSize - pivotid;
}
```
['C']