You are viewing a single comment's thread. Return to all comments →
Using Python Deque. Can this be done in Competitive exams? If no, can this be done simply using a list?
from collections import deque d=deque() q=int(input()) for i in range(q): lst=[int(x) for x in input().split()] if lst[0]==1: d.append(lst[1]) elif lst[0]==2: d.popleft() else: print(d[0])
Seems like cookies are disabled on this browser, please enable them to open this website
Queue using Two Stacks
You are viewing a single comment's thread. Return to all comments →
Using Python Deque. Can this be done in Competitive exams? If no, can this be done simply using a list?