import java.util.LinkedList;
import java.util.Queue;
class Solution {
public int[] solution(int[] prices) {
Queue<Integer> que=new LinkedList<>(Arrays.asList(prices));
int[] answer = new int[prices.length];
int flag=0;
while(!que.isEmpty()) {
int tmp=que.poll();
for(int i=flag;i<prices.length;i++) {
if(prices[i]>=tmp) {
if(i==prices.length-1) {
answer[flag]=i-flag;
break;
}
else {
continue;
}
}
else {
answer[flag]=i-flag;
break;
}
}
flag++;
}
return answer;
}
}
'Algorithm > Stack, Queue' 카테고리의 다른 글
[프로그래머스] 탑 [JAVA] (0) | 2019.11.21 |
---|---|
[프로그래머스] 다리를 지나는 트럭 문제[JAVA] (0) | 2019.11.20 |
[프로그래머스] 프린터 문제 [JAVA] (0) | 2019.11.19 |
[프로그래머스] 기능개발 문제[JAVA] (1) | 2019.11.18 |