-
[Python] 프로그래머스 / 2018 KAKAO BLIND RECRUITMENT / [1차] 추석 트래픽코딩테스트 2024. 9. 19. 20:49
정답 코드
하라는 대로 하기만 하면 되는 간단한 문제.
def solution(lines): times = [] for line in lines: date, time, duration = line.split() hh = int(time[:2]) mm = int(time[3:5]) ss = int(time[6:8]) ms = int(time[9:]) duration = int(float(duration[:-1]) * 1000) end_time = (hh * 3600 + mm * 60 + ss) * 1000 + ms start_time = end_time - duration + 1 times.append((start_time, end_time)) answer = 0 for _, end_time in times : interval_start = end_time interval_end = end_time + 999 cnt = 0 for s, e in times : if s <= interval_end and e >= interval_start : cnt += 1 answer = max(answer, cnt) return answer
'코딩테스트' 카테고리의 다른 글
꿀팁 : defaultdict(list)의 value를 deque()로 만들면 잘 작동되지 않는다. (5) 2024.09.20 [Python] 프로그래머스 / Summer/Winter Coding / 쿠키 구입 (2) 2024.09.19 [Python] 프로그래머스 / 2018 KAKAO BLIND RECRUITMENT / [1차] 셔틀버스 (0) 2024.09.19 [Python] 프로그래머스 / 아이템 줍기 (0) 2024.09.19 [Python] 프로그래머스 / 순위 (2) 2024.09.17