Skip to content

Instantly share code, notes, and snippets.

@zigzackey
Created April 1, 2016 03:49
Show Gist options
  • Save zigzackey/459889e603488e19d80ce06d37eee743 to your computer and use it in GitHub Desktop.
Save zigzackey/459889e603488e19d80ce06d37eee743 to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
from collections import deque
if __name__ == '__main__':
n = int(input())
L = deque()
for i in range(n):
cmdline = input().split()
if cmdline[0] == "insert":
L.appendleft(cmdline[1])
elif cmdline[0] == "delete":
L.remove(cmdline[1])
elif cmdline[0] == "deleteFirst":
L.popleft()
elif cmdline[0] == "deleteLast":
L.pop()
print(" ".join(L))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment