Skip to content

Commit c8f0a18

Browse files
authored
Create maximum-consecutive-floors-without-special-floors.py
1 parent 850e461 commit c8f0a18

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Time: O(nlogn)
2+
# Space: O(1)
3+
4+
# sort
5+
class Solution(object):
6+
def maxConsecutive(self, bottom, top, special):
7+
"""
8+
:type bottom: int
9+
:type top: int
10+
:type special: List[int]
11+
:rtype: int
12+
"""
13+
special.sort()
14+
result = max(special[0]-bottom, top-special[-1])
15+
for i in xrange(1, len(special)):
16+
result = max(result, special[i]-special[i-1]-1)
17+
return result

0 commit comments

Comments
 (0)