minimum right shifts to sort the array in C
IntuitionApproachComplexity
Time complexity:

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

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

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```c []
int minimumRightShifts(int* nums, int numsSize) {
    int count = 0, index;
    for (int i = 0; i < numsSize - 1; i++) {
        if (nums[i] > nums[i + 1]) {
            count++;
            index = i + 1;
        }
    }
    if (nums[numsSize - 1] > nums[0] && count != 0)
        count++; // compare last element with first element-if count!=0
    if (count > 1)
        return -1; // cannot be sorted
    if (count == 0)
        return 0; // already sorted
    return numsSize - index;
}
```
['C']