Solution :
import math
from collections import deque
def solution(progresses, speeds):
# [1] 남은 일 수 구하기
days=[math.ceil((100-i)/k) for i,k in zip(progresses,speeds)]
# print(days)
# 초기화
answer = []
q_days=deque(days)
current_day=q_days.popleft()
count=1
# [2] while 반복문 돌림 + 누적O 및 누적X
while q_days:
if q_days and current_day >= q_days[0]: # 누적O
q_days.popleft() # 작은거 빼버림.
count+=1
else: # 누적X
answer.append(count)
current_day=q_days.popleft()
count=1
answer.append(count)
return answer
Skills :
- 문제의 해결에 따라, popleft()를 while문 외부 및 내부에서 수행함.
- 업데이트 될 때마다 초기화를 else에서 함.
'코딩테스트 > 프로그래머스' 카테고리의 다른 글
[프로그래머스] LV1 데이터분석 | 파이썬 (0) | 2025.05.07 |
---|---|
[프로그래머스] LV2 주식가격 | 파이썬 (0) | 2025.05.07 |
[프로그래머스] LV2 프로세스 | 파이썬 (0) | 2025.05.07 |
[프로그래머스] LV2 다리를 지나는 트럭 | 파이썬 (0) | 2025.05.07 |
[프로그래머스] LV2 의상 | 파이썬 (0) | 2025.05.07 |