Minimum Shifts to Sort the Array - Python3 Easy solution
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
```python3 []
class Solution:
    def minimumRightShifts(self, nums: List[int]) -> int:
        
        if nums == sorted(nums):
            return 0

        # find pivot element
        mini = min(nums)
        ind = -1

        # if ind == 0, then no need to search for rotations
        for i in range(len(nums)):
            if nums[i] == mini:
                ind = i
                break

        # finding the no of rotations
        rotations = 0
        if ind != -1:
            rotations = ((len(nums)) - ind)
        
        points = 0
        if nums[0] < nums[-1]: points += 1
        for i in range(1, len(nums)):
            if nums[i] < nums[i - 1]: points += 1

        return -1 if points > 1 else rotations
     

        

```
['Python3']