You are viewing a single comment's thread. Return to all comments →
from collections import deque def execute(dq, parts): command = parts[0] if len(parts) > 1: arg = int(parts[1]) if command == 'pop': dq.pop() elif command == 'popleft': dq.popleft() elif command == 'append': dq.append(arg) elif command == 'appendleft': dq.appendleft(arg) return dq if __name__ == '__main__': dq = deque() n_ops = int(input()) for _ in range(n_ops): parts = input().split(' ') dq = execute(dq, parts) print(' '.join(str(num) for num in dq))
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 →