Skip to content

Instantly share code, notes, and snippets.

@emayom
Created August 22, 2021 07:47
Show Gist options
  • Save emayom/53462c51921bca3bf582323775900a94 to your computer and use it in GitHub Desktop.
Save emayom/53462c51921bca3bf582323775900a94 to your computer and use it in GitHub Desktop.
[프로그래머스] 기능개발
function solution(progresses, speeds) {
let answer = progresses.map((el, index) => Math.ceil((100 - el) / speeds[index]));
const LENGTH = answer.length;
let temp = [];
let cnt = 1;
let max = answer[0];
for(let i = 1; i < LENGTH; i++){
if(max >= answer[i]){
cnt ++;
} else if (max < answer[i]){
temp.push(cnt);
max = answer[i];
cnt = 1;
}
}
temp.push(cnt);
return temp;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment