You are viewing a single comment's thread. Return to all comments →
Python 3 solution
class Queue: def __init__(self): self.data = [] def enqueue(self, val): self.data.append(val) def dequeue(self): self.data.remove(self.data[0]) def print(self): print(self.data[0]) n = int(input()) queue = Queue() for i in range(n): x = input().split() if x[0] == '1': queue.enqueue(x[1]) if x[0] == '2': queue.dequeue() if x[0] == '3': queue.print()
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 →
Python 3 solution