We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f73d03b commit 69834ccCopy full SHA for 69834cc
JYP/queuestack.py
@@ -0,0 +1,25 @@
1
+from collections import deque
2
+import sys
3
+input = sys.stdin.readline
4
+
5
6
+a = int(input())
7
+sec1 = list(map(int, input().split()))
8
+sec2 = list(map(int, input().split()))
9
+b = int(input())
10
+sec3 = list(map(int, input().split()))
11
12
13
+queue = deque([])
14
+for i in range(a):
15
+ if sec1[i] == 0:
16
+ queue.appendleft(sec2[i])
17
+else:
18
+ if queue == []:
19
+ print(*sec3)
20
+ sys.exit()
21
22
23
+for i in range(b):
24
+ queue.append(sec3[i])
25
+ print(queue.popleft(), end = " ")
0 commit comments