题目链接:2274. 不含特殊楼层的最大连续楼层数 - 力扣(LeetCode)
题解
参考代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
class Solution: def maxConsecutive(self, bottom: int, top: int, special: List[int]) -> int: special.sort() ans = special[0] - bottom if len(special) > 0 else top-bottom+1 for i in range(1, len(special)): ans = max(ans, special[i] - special[i-1] - 1) ans = max(ans, top-special[-1] if len(special) > 0 else top-bottom+1) return ans
|