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.
2 parents 525393a + 1239491 commit fb3eec9Copy full SHA for fb3eec9
LiiNi-coder/202511/19 PGM 택배상자.md
@@ -0,0 +1,43 @@
1
+```java
2
+import java.util.*;
3
+
4
+class Solution {
5
+ public int solution(int[] order) {
6
+ int answer = 0;
7
+ Queue<Integer> main = new LinkedList<>();
8
+ for(int i = 1; i <= order.length; i++)
9
+ main.offer(i);
10
11
+ Deque<Integer> sub = new ArrayDeque<>();
12
+ int index = 0;
13
14
+ for(int target : order){
15
+ while(true){
16
+ if(!main.isEmpty() && main.peek() <= target){
17
+ if(main.peek() == target){
18
+ main.poll();
19
+ answer++;
20
21
+ break;
22
+ } else {
23
+ sub.offer(main.poll());
24
+ }
25
26
+ if(!sub.isEmpty() && sub.peek() == target){
27
+ sub.poll();
28
29
30
31
32
+ else {
33
+ return answer;
34
35
36
37
38
39
40
41
+}
42
43
+```
0 commit comments