Skip to content

Commit 5ff8112

Browse files
committed
feat: Solve meeting-rooms-ii problem
1 parent 7507b00 commit 5ff8112

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

meeting-rooms-ii/hu6r1s.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
from typing import (
2+
List,
3+
)
4+
from lintcode import (
5+
Interval,
6+
)
7+
8+
"""
9+
Definition of Interval:
10+
class Interval(object):
11+
def __init__(self, start, end):
12+
self.start = start
13+
self.end = end
14+
"""
15+
from heapq import heappush, heappop
16+
17+
class Solution:
18+
"""
19+
@param intervals: an array of meeting time intervals
20+
@return: the minimum number of conference rooms required
21+
"""
22+
def min_meeting_rooms(self, intervals: List[Interval]) -> int:
23+
# Write your code here
24+
intervals.sort()
25+
ends = []
26+
for start, end in intervals:
27+
if ends and ends[0] <= start:
28+
heappop(ends)
29+
heappush(ends, end)
30+
return len(ends)

0 commit comments

Comments
 (0)