You are viewing a single comment's thread. Return to all comments →
from collections import deque n = int(input()) dek =deque()
for i in range(n): command = list(input().split()) if command[0] == 'append': dek.append(int(command[1]))
elif command[0] == 'appendleft': dek.appendleft(int(command[1])) elif command[0] == 'pop': dek.pop() elif command[0] == 'popleft': dek.popleft()
print(*dek)
Seems like cookies are disabled on this browser, please enable them to open this website
Collections.deque()
You are viewing a single comment's thread. Return to all comments →
from collections import deque n = int(input()) dek =deque()
for i in range(n): command = list(input().split()) if command[0] == 'append': dek.append(int(command[1]))
print(*dek)