[プログラマ]機能の開発(JAVA)
質問する
https://programmers.co.kr/learn/courses/30/lessons/42586
マイコード
class Program{
int progress;
int speed;
public Program(int progress, int speed) {
this.progress = progress;
this.speed = speed;
}
}
public List<Integer> solution(int[] progresses, int[] speeds) {
List<Integer> rlt = new ArrayList<>();
//2
Queue<Program> queue = new LinkedList<>();
for(int i=0; i<progresses.length; i++) {
queue.offer(new Program(progresses[i], speeds[i]));
}
//3
while(!queue.isEmpty()){
int count = 0;
//4
for(int i=0; i<queue.size(); i++) {
Program temp = queue.poll();
temp.progress += temp.speed;
queue.offer(temp);
}
//5
while(queue.size()>0) {
if(queue.peek().progress >= 100) {
queue.poll();
count++;
}else {
break;
}
}
//6
if(count >0)
rlt.add(count);
}
return rlt;
}
に答える
Reference
この問題について([プログラマ]機能の開発(JAVA)), 我々は、より多くの情報をここで見つけました https://velog.io/@jess29/프로그래머스기능개발JAVAテキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol