题解 | #【模板】队列#
【模板】队列
https://www.nowcoder.com/practice/afe812c80ad946f4b292a26dd13ba549
s = []
num = int(input())
for i in range(num):
a = input()
if a[0:4] == 'push':
s.append(int(a.split()[1]))
else:
if not s:
print('error')
else:
print(s[0])
if a == 'pop':
s.pop(0)
跟AB1没什么区别,单纯是输出和删除的位置变化了一下。push还是append配合split,删除是pop(0)。
#日常刷题#
美团成长空间 2663人发布