Search

기능개발

알고리즘
스택/큐
플랫폼
프로그래머스
JCF
상태
해결
생성 일시
2023/12/19 10:34
최종 편집 일시
2023/12/19 11:32

문제 설명

해결과정

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
복사