You are viewing a single comment's thread. Return to all comments →
from collections import deque
if name == 'main': N = int(input()) d = deque()
for _ in range(N): command = input().split() operation = command[0] if operation == "append": d.append(int(command[1])) elif operation == "appendleft": d.appendleft(int(command[1])) elif operation == "pop": d.pop() elif operation == "popleft": d.popleft() print(" ".join(map(str, d)))
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
if name == 'main': N = int(input()) d = deque()