Skip to content

Latest commit

 

History

History
38 lines (28 loc) · 908 Bytes

_1752. Check if Array Is Sorted and Rotated.md

File metadata and controls

38 lines (28 loc) · 908 Bytes

All prompts are owned by LeetCode. To view the prompt, click the title link above.

Back to top


First completed : February 02, 2025

Last updated : February 02, 2025


Related Topics : Array

Acceptance Rate : 54.95 %


Solutions

Python

class Solution:
    def check(self, nums: List[int]) -> bool:
        allowance_used = False
        for i, j in zip(nums[:-1], nums[1:]) :
            if i <= j :
                continue
            if allowance_used :
                return False
            allowance_used = True
        return not allowance_used or (nums[0] >= nums[-1])