242. 기능개발
1) 어떤 전략(알고리즘)으로 해결?
2) 코딩 설명
<내 풀이>
from collections import deque
def solution(progresses, speeds):
answer = []
progress = deque(progresses)
speeds = deque(speeds)
while progress :
if progress[0]<100 :
for p in range(len(progress)) :
progress[p]+=speeds[p]
else :
candidates = []
while progress and progress[0]>=100 :
candidates.append(progress.popleft())
speeds.popleft()
answer.append(len(candidates))
return answer
< 내 틀렸던 풀이, 문제점>
테케 1,5,6, 만 통과
def solution(progresses, speeds):
answer = []
progress = deque(progresses)
speeds = deque(speeds)
while progress :
if progress[0]<100 :
for p in range(len(progress)) :
progress[p]+=speeds[p]
else :
candidates = []
while progress and progress[0]>=100 :
candidates.append(progress.popleft())
answer.append(len(candidates))
return answer
- progress 가 popleft 돼서 제거될 때, 그에 상응하는 speed 도 popleft 됐어야 하는데, 그것을 안해줬었다!
<반성 점>
<배운 점>