Created
August 22, 2021 07:47
-
-
Save emayom/53462c51921bca3bf582323775900a94 to your computer and use it in GitHub Desktop.
[프로그래머스] 기능개발
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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