

int[] arr = new int[progresses.length];
for(int i = 0 ;i<progresses.length; i++){
int spear = 100 - progresses[i];
if (spear % speeds[i] == 0){
arr[i] = spear / speeds[i];
} else
arr[i] = spear / speeds[i] +1;
}
int n = arr[0];
int count = 1;
ArrayList<Integer> list = new ArrayList<>();
for(int i = 1; i<arr.length; i++){
if(arr[i] <= n){
count++;
} else {
list.add(count);
n = arr[i];
count = 1;
}
}
list.add(count);
return list;
import java.util.*;
class Solution {
public ArrayList<Integer> solution(int[] progresses, int[] speeds) {
int[] arr = new int[progresses.length];
for(int i = 0 ;i<progresses.length; i++){
int spear = 100 - progresses[i];
if (spear % speeds[i] == 0){
arr[i] = spear / speeds[i];
} else
arr[i] = spear / speeds[i] +1;
}
int n = arr[0];
int count = 1;
ArrayList<Integer> list = new ArrayList<>();
for(int i = 1; i<arr.length; i++){
if(arr[i] <= n){
count++;
} else {
list.add(count);
n = arr[i];
count = 1;
}
}
list.add(count);
return list;
}
}
사실 90.9점까지는 풀었는데, 2번과 11번 테스트케이스에서 실패하고 질문게시판의 반례를 찾아봤다. 입력값 [90, 90], [10, 9] 출력값 [1, 1]인데 내 결괏값은 자꾸 [2]가 나왔다. 알고보니 풀이 1에서 arr에 개발에 필요한 소요일수를 저장하면서 계산식에 %대신 /를 잘못 작성했더라 .. 돌이켜보니 Math.ceil()함수를 썼으면 간단했을 듯