题目:https://www.hackerrank.com/challenges/py-collections-deque/problem
题意:deque的基本操作
思路:基本操作
代码:
'''
-*- coding: utf-8 -*-
@Author : PlayerGuan
@Time : 2017/10/14 23:12
@Software: PyCharm Community Edition
@File : main.py
'''
from collections import deque
n = int(input())
dq = deque()
for i in range(n):
s = input().split()
if s[0] == 'append':
dq.append(s[1])
elif s[0] == 'appendleft':
dq.appendleft(s[1])
elif s[0] == 'pop':
dq.pop()
else:
dq.popleft()
print(' '.join(dq))