Easy C++ solution || Beats 100%
IntuitionSimilar to rotate arrayApproachCheck if there is more than one occurance where next element is smaller than prev, i.e. not sorted.Complexity
Time compl
# Intuition
Similar to rotate array

# Approach
Check if there is more than one occurance where next element is smaller than prev, i.e. not sorted.

# Complexity
- Time complexity:
O(n)
- Space complexity:
O(1)
# Code
```cpp []
class Solution {
public:
    int minimumRightShifts(vector<int>& nums) {
        int n = nums.size(), res = n;
        for(int i = 1; i < n; i++) {
            if(nums[i] >= nums[i - 1]) continue;
            if(res != n) return -1;
            else res = i;
        }
        return (res != n && nums.back() > nums[0]) ? -1 : n - res;
    }
};
```
['C++']