题解 | 【模板】队列操作

【模板】队列操作

https://www.nowcoder.com/practice/1137c8f6ffac4d5d94cc1b0cb08723f9

from sys import stdin
from collections import *
from random import *
input = lambda: stdin.readline().strip()
# read1 = stdin.read().split()
# idx = 1
l = deque()
for _ in range(int(input())):
    x = input().split()
    if x[0] == "1":
        l.append(x[1])
    elif x[0] == "2":
        try:
            l.popleft()
        except:
            print("ERR_CANNOT_POP")
    elif x[0] == "3":
        try:
            print(l[0])
        except:
            print("ERR_CANNOT_QUERY")
    else:
        print(len(l))


全部评论

相关推荐

09-14 17:23
门头沟学院
故事和酒66:所以说副业很重要,程序员干到40岁,再怎么也赚300万了,吃吃利息也够活下去
点赞 评论 收藏
分享
昨天 16:42
井冈山大学 Java
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务