2274. Maximum Consecutive Floors Without Special Floors

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

On This Page

LeetCode problem 2274

class Solution:
    def maxConsecutive(self, bottom: int, top: int, special: List[int]) -> int:
        special.sort()
        res = max(special[0] - bottom, top - special[-1])
        for i in range(1, len(special)):
            res = max(res, special[i] - special[i - 1] - 1)
        return res