[Python3] 9 lines, no sort, T/S: 45ms/16mb (beats 100% /100%)
\n\n# Complexity\n- Time complexity O(n):\n- Space complexity O(1):\n\n# Code\n\nclass Solution:\n    def minimumRightShifts(self, nums: List[int]) -> int:\n   
![Screenshot 2023-09-17 173213.png](https://assets.leetcode.com/users/images/88a47eef-2126-48b2-81af-fd98c576da9f_1694965281.4732218.png)\n\n# Complexity\n- Time complexity $$O(n)$$:\n- Space complexity $$O(1)$$:\n\n# Code\n```\nclass Solution:\n    def minimumRightShifts(self, nums: List[int]) -> int:\n        n = len(nums)\n        # If the last-first pair breaks cycle ordering, store n into broken\n        # >= here handles the case of one-element array\n        broken = n if nums[-1] >= nums[0] else 0\n\n        # Iterate from right to left:\n        # we are interested in the rightmost element that breaks ordering\n        for i in range(n - 1, 0, -1):\n            if nums[i] < nums[i - 1]:\n                if broken:\n                    # If we have already found an element breaking ordering, return -1\n                    return -1\n                else:\n                    # Memorize the element breaking ordering\n                    broken = i\n        return n - broken\n```
['Python3']