Simplest Code: Beats 100%
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)
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

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

# Code
```cpp []
class Solution {
public:
    int minimumRightShifts(vector<int>& nums) {
        int n = nums.size();
        
        // Find the pivot point where the array drops (i.e., nums[i] < nums[i-1])
        int pivot = -1;
        for (int i = 1; i < n; i++) {
            if (nums[i] < nums[i - 1]) {
                if (pivot != -1) {
                    // More than one drop means it's impossible to sort by shifts
                    return -1;
                }
                pivot = i;
            }
        }

        // If no pivot is found, the array is already sorted, so no shifts are needed
        if (pivot == -1) return 0;

        // Check if rotating the array at the pivot point results in a sorted array
        for (int i = 1; i < n; i++) {
            if (nums[(pivot + i) % n] < nums[(pivot + i - 1 + n) % n]) {
                return -1;
            }
        }

        // If we can rotate to get a sorted array, the number of shifts is n - pivot
        return n - pivot;
    }
};
```
['C++']