본문 바로가기
python-algorithm

leetcode 1752. Check if Array Is Sorted and Rotated

by 무적김두칠 2022. 4. 18.

1
2
3
4
5
6
7
8
9
10
11
class Solution:
    def check(self, nums: List[int]) -> bool:
        ans = False
        target=sorted(nums)
        for i in range(len(nums)):
            nums.append(nums[0])
            nums.pop(0)
            if nums == target :
                ans=True
                break
        return(ans)
cs
반응형

'python-algorithm' 카테고리의 다른 글

leetcode 345. Reverse Vowels of a String  (0) 2022.04.21
leetcode 504. Base 7  (0) 2022.04.18
leetcode 1796. Second Largest Digit in a String  (0) 2022.04.18
leetcode 1154. Day of the Year  (0) 2022.04.18
leetcode 796. Rotate String  (0) 2022.04.18

댓글