We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7b80763 commit 82d3d42Copy full SHA for 82d3d42
ksinji/202511/5 PGM 프로세스.md
@@ -0,0 +1,33 @@
1
+```java
2
+import java.util.*;
3
+
4
+class Solution {
5
+ public int solution(int[] priorities, int location) {
6
+ int[] cnt = new int[10];
7
+ for (int p : priorities) cnt[p]++;
8
9
+ ArrayDeque<int[]> q = new ArrayDeque<>();
10
+ for (int i = 0; i < priorities.length; i++) q.offer(new int[]{priorities[i], i});
11
12
+ int cur = 9;
13
+ while (cur > 0 && cnt[cur] == 0) cur--;
14
15
+ int order = 0;
16
+ while (!q.isEmpty()) {
17
+ int[] doc = q.poll();
18
+ int p = doc[0], idx = doc[1];
19
20
+ if (p == cur) {
21
+ order++;
22
+ cnt[p]--;
23
+ if (idx == location) return order;
24
25
+ } else {
26
+ q.offer(doc);
27
+ }
28
29
+ return -1;
30
31
+}
32
33
+```
0 commit comments