2024/04/261 leetcode 2855. Minimum Right Shifts to Sort the Array https://leetcode.com/problems/minimum-right-shifts-to-sort-the-array/description/ 123456789class Solution: def minimumRightShifts(self, nums: List[int]) -> int: sorted_nums = sorted(nums) for i in range(len(nums)): if nums == sorted_nums: return i nums = nums[-1: -2: -1] + nums[:len(nums)-1] return -1Colored by Color Scriptercs 2024. 4. 26. 이전 1 다음