Skip to content

Commit 3d56dd3

Browse files
author
hangyeol
committed
94차 2번 문제풀이
1 parent 9e4d9f0 commit 3d56dd3

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

live9/test94/문제2/백한결.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import heapq
2+
3+
def solution(book_time):
4+
5+
book_time.sort()
6+
7+
start = []
8+
end = []
9+
10+
for time in book_time:
11+
start.append(hourToMinute(time[0]))
12+
end.append(hourToMinute(time[1]) + 10)
13+
14+
rooms = []
15+
heapq.heapify(rooms)
16+
17+
for i in range(len(book_time)):
18+
if rooms and rooms[0] <= start[i]:
19+
heapq.heappop(rooms)
20+
21+
heapq.heappush(rooms, end[i])
22+
23+
return len(rooms)
24+
25+
def hourToMinute(time):
26+
hour, minute = time.split(":")
27+
28+
minutes = int(hour) * 60 + int(minute)
29+
30+
return minutes

0 commit comments

Comments
 (0)