Created
August 21, 2020 16:31
-
-
Save yungyungGwon/4bc98392c7a9eb839bc65640c2df0c00 to your computer and use it in GitHub Desktop.
Algorithm
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){ | |
var answer = []; | |
var check = []; | |
var bound, rest, day, temp = 0; | |
for(var i = 0; i < progresses.length; i++){ | |
rest = 100 - progresses[i]; | |
if(rest % speeds[i] == 0){ | |
day = rest / speeds[i]; | |
} | |
else{ | |
day = parseInt(rest / speeds[i]) + 1; | |
} | |
check.push(day); | |
} | |
bound = check[0]; | |
for(var j = 0 ; j < check.length; j++){ | |
if(bound >= check[j]){ | |
temp += 1; | |
} | |
else{ | |
answer.push(temp); | |
bound = check[j]; | |
temp = 1; | |
} | |
} | |
answer.push(temp); | |
return answer; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment