-
[프로그래머스] 호텔 대실 LV2Python/Programmers 2023. 2. 19. 20:42728x90
문제)
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
알고리즘)
-그리디 알고리즘
코드)
from heapq import heappop, heappush def solution(book_time): temp = [] cnt = 0 chk_list = [(int(s[:2])*60 + int(s[3:]), int(e[:2])*60 + int(e[3:])) for s,e in book_time] chk_list.sort() for s,e in chk_list: if not(temp): cnt += 1 heappush(temp, e) continue if temp[0] <= s: heappop(temp) else: cnt += 1 heappush(temp, e+10) return cnt
728x90'Python > Programmers' 카테고리의 다른 글
[프로그래머스] 당구 연습 LV2 (0) 2024.02.23 [프로그래머스] 광물 캐기 LV2 (0) 2024.02.07 [프로그래머스] 숫자 카드 나누기 LV2 (0) 2023.08.08 [프로그래머스] 미로 탈출 LV2 (0) 2023.02.19