def solution(book_time):
# 시간을 분으로 변환
times = []
for i in book_time:
start = i[0]
end = i[1][:-2] + str(int(i[1][-2:]) + 10)
start_h, start_m = map(int, start.split(":"))
start_minutes = start_h * 60 + start_m
end_h, end_m = map(int, end.split(":"))
end_minutes = end_h * 60 + end_m
times.append((start_minutes, end_minutes))
times.sort()
rooms = []
for time in times:
# rooms이 비어있으면 우선 하나 추가
if not rooms:
rooms.append(time)
continue
# 가장 빨리 나오는 시간대 찾기
first_out = min(rooms, key=lambda x: x[1])
# 현재의 입실 시간이 가장 빠른 퇴실 시간보다 작을 경우
# 퇴실 없이 방 추가
if time[0] < first_out[1]:
rooms.append(time)
# 현재 입실 시간이 가장 빠른 퇴실 시간보다 클 경우
# 퇴실 하나 하고, 입실
else:
rooms.append(time)
rooms.remove(first_out)
return len(rooms)
PREVIOUS[백준] 색종이 만들기