-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMeeting Rooms II
49 lines (41 loc) · 1023 Bytes
/
Meeting Rooms II
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
from typing import (
List,
)
from lintcode import (
Interval,
)
"""
Definition of Interval:
class Interval(object):
def __init__(self, start, end):
self.start = start
self.end = end
"""
class Solution:
"""
@param intervals: an array of meeting time intervals
@return: the minimum number of conference rooms required
"""
def min_meeting_rooms(self, intervals: List[Interval]) -> int:
# Write your code here
A = []
D = []
for i in range(len(intervals)):
curr = intervals[i]
A.append(curr.start)
D.append(curr.end)
A.sort()
D.sort()
maxRooms = 0
count = 0
start = 0
end = 0
while start < len(intervals):
if A[start] < D[end]:
count += 1
start += 1
else:
count -= 1
end += 1
maxRooms = max(maxRooms, count)
return maxRooms