#后进先出:栈
class stack(object):
    def __init__(self):
        self.data =[]

    def push(self,item):
        self.data.append(item)

    def pop(self):
        return self.data.pop()

#先进先出:队列

class Queue(object):
    def __init__(self):
        self.data=[]

    def push(self,item):
        self.data.insert(0,item)

    def pop(self):
        return self.data.pop()


    

  

相关文章:

  • 2021-06-19
  • 2022-12-23
  • 2022-01-14
  • 2021-06-26
  • 2021-09-17
  • 2022-12-23
  • 2021-06-05
猜你喜欢
  • 2021-10-14
  • 2021-10-15
  • 2021-10-26
  • 2022-01-05
相关资源
相似解决方案