Skip to content

Commit f164643

Browse files
committed
[PGS] 기능개발 / Level2 (Java 풀이) / 30분 / 힌트, 성공
1 parent 8612d03 commit f164643

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import java.util.*;
2+
3+
class Solution {
4+
public int[] solution(int[] progresses, int[] speeds) {
5+
ArrayList<Integer> answer = new ArrayList<>();
6+
ArrayList<Integer> queue = new ArrayList<>();
7+
8+
for (int i=0; i < progresses.length; i++){
9+
int days = (int) Math.ceil((100.0 - progresses[i]) / speeds[i]);
10+
if (queue.size() > 0 && days > queue.get(0)) {
11+
answer.add(queue.size());
12+
queue.clear();
13+
queue.add(days);
14+
15+
}
16+
else {
17+
queue.add(days);
18+
}
19+
}
20+
answer.add(queue.size());
21+
22+
// 배열로 변환
23+
int[] arr = answer.stream()
24+
.mapToInt(Integer::intValue)
25+
.toArray();
26+
27+
return arr;
28+
}
29+
}

0 commit comments

Comments
 (0)