跳到主要内容

2274.不含特殊楼层的最大连续楼层数

链接:2274.不含特殊楼层的最大连续楼层数
难度:Medium
标签:数组、排序
简介:返回不含特殊楼层的 最大 连续楼层数。

题解 1 - python

  • 编辑时间:2025-01-06
  • 执行用时:107ms
  • 内存消耗:31.85MB
  • 编程语言:python
  • 解法介绍:两两结对遍历
class Solution:
def maxConsecutive(self, bottom: int, top: int, special: List[int]) -> int:
return max(v2 - v1 - 1 for v1, v2 in pairwise(sorted(special + [bottom - 1] + [top + 1])))