5회차: 24/07/23 21:00 ~ 24:00
장소: zoom
계획: 24년 하계 모각코
스터디 주제 : 큐 자료구조를 활용하여 문제 해결하기
https://www.codetree.ai/missions/6/problems/process-numeric-commands-2/description
스터디 목표 : 코드트리 문제를 미리 선정하여 해결하기


from collections import deque
class Queue:
def __init__(self):
self.dq = deque()
def push(self, item):
self.dq.append(item)
def empty(self):
return not self.dq
def size(self):
return len(self.dq)
def pop(self):
if self.empty():
raise Exception("Queue is empty")
return self.dq.popleft()
def front(self):
if self.empty():
raise Exception("Queue is empty")
return self.dq[0]
n = int(input())
q = Queue()
for _ in range(n):
command = input()
if command.startswith("push"):
x = int(command.split()[1])
q.push(x)
elif command == "pop":
print(q.pop())
elif command == "size":
print(q.size())
elif command == "empty":
print(1 if q.empty() else 0)
else:
print(q.front())
