- 난이도: Lv2
프로그래머스 링크: https://school.programmers.co.kr/learn/courses/30/lessons/42586
풀이 링크(GitHub): hayannn/CodingTest_Java/프로그래머스/2/기능 개발
풀이 시간 : 45분
import java.util.*;
class Solution {
public int[] solution(int[] progresses, int[] speeds) {
List<Integer> result = new ArrayList<>();
int n = progresses.length;
int[] days = new int[n];
for (int i = 0; i < n; i++) {
days[i] = (100 - progresses[i] + speeds[i] - 1) / speeds[i];
}
int maxDay = days[0];
int count = 0;
for (int day : days) {
if (day <= maxDay) {
count++;
} else {
result.add(count);
count = 1;
maxDay = day;
}
}
result.add(count);
int[] answer = result.stream().mapToInt(i -> i).toArray();
return answer;
}
}