```
import java.util.LinkedList;
import java.util.Queue;
class Solution {
public int solution(int[] priorities, int location) {
Queue q =new LinkedList<>();
for(int p:priorities) {
q.offer(p);
}
int count=0;
while(!q.isEmpty()) {
int item = q.poll();
boolean check = true;
for(int s:q) {
if(item<s) {
check=false;
}
}
if(check) {
count++;
if(location==0)
return count;
}else {
q.offer(item);
}
location--;
if(location<0)location+=q.size();
}
return count;
}
}
```
'알고리즘' 카테고리의 다른 글
[Java]프로그래머스 위장 (0) | 2019.04.15 |
---|---|
[Java]프로그래머스 쇠막대기 (0) | 2019.04.15 |
[Java]프로그래머스 스킬트리 (0) | 2019.04.15 |
[Java] 프로그래머스 주식가격 (0) | 2019.04.15 |
[Java] 프로그래머스 기능개발 (0) | 2019.04.15 |