https://programmers.co.kr/learn/courses/30/lessons/42586?language=java
코딩테스트 연습 - 기능개발
프로그래머스 팀에서는 기능 개선 작업을 수행 중입니다. 각 기능은 진도가 100%일 때 서비스에 반영할 수 있습니다. 또, 각 기능의 개발속도는 모두 다르기 때문에 뒤에 있는 기능이 앞에 있는
programmers.co.kr
package programmers.stackandqueue;
import java.util.Arrays;
public class Solution {
public int[] solution(int[] progresses, int[] speeds) {
int[] answer = new int[100];
int day = 0;
for (int i = 0; i < progresses.length; i++) {
while (progresses[i] + (speeds[i] * day) < 100) {
day++;
}
answer[day] += 1;
}
// 0이 아닌 요소만 꺼내서 리턴해주기
return Arrays.stream(answer).filter(i -> i!=0).toArray();
}
public static void main(String[] args) {
Solution sol = new Solution();
System.out.println(Arrays.toString(sol.solution(new int[]{93, 30, 55}, new int[]{1, 30, 5})));
}
}
728x90
반응형
'Algorithm > 프로그래머스' 카테고리의 다른 글
스택/큐 - 프린터 (0) | 2022.03.21 |
---|---|
정렬 - K번째 수 (0) | 2022.03.10 |
프로그래머스 - 모의고사 (0) | 2022.03.05 |
프로그래머스 - 체육복 (0) | 2021.04.08 |