문제 설명
해결과정
Solution.java
import java.util.*;
class Solution {
public int[] solution(int[] progresses, int[] speeds) {
boolean developmentCompleted = true;
int[] periods = new int[speeds.length];
int index = 0;
for(int progress : progresses) {
int period = 100 - progress;
int estimatedPeriod = period/speeds[index];
int realPeriod = 100 > progress + (estimatedPeriod*speeds[index]) ? estimatedPeriod+1 : estimatedPeriod;
periods[index] = realPeriod;
index++;
}
String str = "";
int deployment = periods[0];
int cnt = 0;
for(int period : periods) {
if(period <= deployment) {
cnt++;
} else {
str += cnt + ",";
cnt = 1;
deployment = period;
}
}
str += cnt;
String[] temp = str.split(",");
int[] answer = new int [temp.length];
int count = 0;
for(int i = 0; i < temp.length; i++) {
int a = Integer.parseInt(temp[i]);
answer[i] = a;
// count += a;
}
// answer[answer.length-1] = speeds.length - count;
return answer;
}
}
Java
복사