We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent fcd66ac commit 11ea1d0Copy full SHA for 11ea1d0
1 file changed
2025-08-27/김태민/프로그래머스_프로세스.java
@@ -0,0 +1,32 @@
1
+import java.util.*;
2
+class Solution {
3
+ public int solution(int[] priorities, int location) {
4
+ int answer = 1;
5
+ Queue<int[]> q = new LinkedList<>();
6
+ PriorityQueue<Integer> pq = new PriorityQueue<>(Collections.reverseOrder());
7
+ for (int i = 0 ; i < priorities.length ; i++) {
8
+ q.offer(new int[]{i, priorities[i]});
9
+ pq.offer(priorities[i]);
10
+ }
11
+
12
+ while(!q.isEmpty()) {
13
+ int [] a = q.peek();
14
15
+ if (a[1] >= pq.peek()) {
16
+ if (a[0] == location) {
17
18
+ return answer;
19
20
21
+ q.poll();
22
+ pq.poll();
23
+ answer++;
24
+ } else {
25
26
+ q.offer(a);
27
28
29
30
31
32
+}
0 commit comments