Leetcode The finger of the sword Offer 09 The reference code for the solution of the problem is as follows :
class CQueue:
def __init__(self):
self.queue=[]
def appendTail(self, value: int) -> None:
self.queue.append(value)
def deleteHead(self) -> int:
try:
value=self.queue.pop(0)
return value
except Exception:
return -1
# Your CQueue object will be instantiated and called as such:
# obj = CQueue()
# obj.appendTail(value)
# param_2 = obj.deleteHead()
Topic link :
https://leetcode.cn/problems/yong-liang-ge-zhan-shi-xian-dui-lie-lcof