문제
기능개발
문제풀이
function solution(progresses, speeds) {
var answer = [];
var days = [];
for (var i = 0; i < progresses.length; i++) {
var leftDays = 100 - progresses[i];
var takeDays = Math.ceil(leftDays / speeds[i]);
days.push(takeDays);
}
var daysCompare = days[0];
var stack = [1];
for (var j = 1; j < days.length; j++) {
if (daysCompare >= days[j]) {
stack.push(1);
}
else {
daysCompare = days[j];
answer.push(stack.length);
stack = [1];
}
}
if(stack.length > 0) {
answer.push(stack.length);
}
return answer;
}