Simplest Solution - Number Of Valleys
Complexity

Time complexity:O(n)


Space complexity: O(1)

Code
# Complexity
- Time complexity:O(n)


- Space complexity: O(1)

# Code
```cpp []
class Solution {
public:
    int minimumRightShifts(vector<int>& nums) {
        int indexMaxNumber {};
        int numberOfValleys {};

        int n = nums.size();
        for(int i = 0; i < n; ++i){
            if(nums[i] > nums[(i + 1) % n]) {
                ++numberOfValleys;
                indexMaxNumber = i;
            }
        }

        return numberOfValleys > 1 ? -1 : numberOfValleys == 1 ? n - indexMaxNumber - 1 : 0;
    }
};
```
['C++']