题目描述:
代码:
class CQueue(object):
def __init__(self):
#构造两个列表,列表B倒序存储列表A
self.A=[]
self.B=[]
def appendTail(self, value):
#添加元素
self.A.append(value)
def deleteHead(self):
if self.B:
return self.B.pop()
elif self.A and not self.B:
while self.A:
self.B.append(self.A.pop())
return self.B.pop()
elif not self.A and not self.B:
return -1