Created
April 1, 2016 03:49
-
-
Save zigzackey/459889e603488e19d80ce06d37eee743 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- 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