import java.util.*;
class Solution {
public int solution(int[] priorities, int location) {
int answer = 1;
PriorityQueue<Integer> pq = new PriorityQueue<>(Collections.reverseOrder());
for(int p : priorities) { pq.add(p); }
while(!pq.isEmpty()) {
for(int i=0; i<priorities.length; i++) {
if(pq.peek()==priorities[i]) {
if(i==location) { return answer; }
pq.poll();
answer++;
}
}
}
return answer;
}
}
'Problem Solving > Programmers' 카테고리의 다른 글
[Level 2] 소수 찾기 (0) | 2022.03.31 |
---|---|
[Level 2] 가장 큰 수 (0) | 2022.03.31 |
[Level 2] 전화번호 목록 (0) | 2022.03.31 |
[Level 2] 튜플 (0) | 2022.03.31 |
[Level 2] [1차] 뉴스 클러스터링 (0) | 2022.03.31 |