문제 링크
기능 개발
풀이
import java.util.ArrayList;
class Solution {
public int[] solution(int[] progresses, int[] speeds) {
ArrayList<Integer> answer = new ArrayList<>();
ArrayList<Integer> days = new ArrayList<>();
for (int i = 0; i < progresses.length; i++) {
int day = (100 - progresses[i]) / speeds[i];
if ((100 - progresses[i]) % speeds[i] > 0) day += 1;
days.add(day);
}
int standardDay = days.get(0);
int deployCnt = 1;
for (int i = 1; i < days.size(); i++) {
if (days.get(i) <= standardDay) {
deployCnt++;
} else {
answer.add(deployCnt);
standardDay = days.get(i);
deployCnt = 1;
}
if(i == days.size() - 1){
answer.add(deployCnt);
}
}
return answer.stream().mapToInt(Integer::intValue).toArray();
}
}
소감