https://leetcode.com/problems/minimum-right-shifts-to-sort-the-array/description/
1 2 3 4 5 6 7 8 9 | class 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 -1 | cs |
반응형
'python-algorithm' 카테고리의 다른 글
leetcode 3131. Find the Integer Added to Array I (0) | 2024.04.30 |
---|---|
leetcode 1266. Minimum Time Visiting All Points (1) | 2024.04.27 |
leetcode 3074. Apple Redistribution into Boxes (0) | 2024.04.25 |
leetcode 1137. N-th Tribonacci Number (0) | 2024.04.25 |
leetcode 3065. Minimum Operations to Exceed Threshold Value I (0) | 2024.04.24 |
댓글