[프로그래머스 Lv.2] 알고리즘 고득점 Kit 스택/큐 - 기능개발

김민지·2024년 4월 7일
0

✨ 정답 ✨

function solution(progresses, speeds) {
    let time=[];
    progresses.map((el, index)=>time.push(Math.ceil((100-el)/speeds[index])));
    let answer=[];
    let max=time[0];
    let count=1;
    for (let i=1;i<time.length;i++){
        if (time[i]<=max){
            count+=1;
        }else{
            answer.push(count)
            max=time[i];
            count=1;
        }
        if (i===time.length-1){
            answer.push(count)
        }
    }
    return answer
}

🧵 참고한 정답지 🧵

💡💡 기억해야 할 점 💡💡

profile
이건 대체 어떻게 만든 거지?

0개의 댓글

Powered by GraphCDN, the GraphQL CDN