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