Skip to content

Instantly share code, notes, and snippets.

@yungyungGwon
Created August 21, 2020 16:31
Show Gist options
  • Save yungyungGwon/4bc98392c7a9eb839bc65640c2df0c00 to your computer and use it in GitHub Desktop.
Save yungyungGwon/4bc98392c7a9eb839bc65640c2df0c00 to your computer and use it in GitHub Desktop.
Algorithm
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