程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Leetcode sword finger offer 09. implement queue Python 3 with two stacks

編輯:Python

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 


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved