2229. Check if an Array Is Consecutive

Updated: 2024-03-12
1 min read
[]

On This Page

LeetCode problem 2229

class Solution:
    def isConsecutive(self, nums: List[int]) -> bool:
        mi, mx = min(nums), max(nums)
        n = len(nums)
        return len(set(nums)) == n and mx == mi + n - 1