코딩테스트 연습

[programmers] 기능개발 / 큐

콩콩(๓° ˘ °๓)♡ 2023. 4. 29. 17:04
 

프로그래머스

코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.

programmers.co.kr

def solution(progresses, speeds):
    answer = []
    endIndex = 0  # 실제 배포가 끝난 index

    # for j in range(10): 로직 개발시 임의로 for값을 제한하는 것이 풀기 쉽다!
    while True:
        endCount = 0  # 배포된 수를 계산
        for i in range(endIndex, len(progresses)):
            progresses[i] += speeds[i]

        for i in range(endIndex, len(progresses)):
            if progresses[i] >= 100:
                endIndex += 1
                endCount += 1
            else:
                break
        if endCount != 0:
            answer.append(endCount)

        if endIndex == len(progresses):
            break
        # print('progress : ', progresses)
        # print('endIndex : ', endIndex)
        # print('endCount : ', endCount)
    return answer