1 Star 0 Fork 0

zhyw/pythonLearn

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
MinStack.py 457 Bytes
一键复制 编辑 原始数据 按行查看 历史
janfrost 提交于 2014-11-13 01:14 +08:00 . leecode
class MinStack:
def __init__(self):
self.L=[]
self.min = []
def pop(self):
minx = self.L.pop()
if self.L.count(minx)<=0 and self.min.count(minx)>0:
self.min.remove(minx)
return minx
def push(self,x):
if not self.min or x< self.min[-1]:
self.min.append(x)
self.L.append(x)
def top(self):
return self.L[-1]
def getMin(self):
return self.min[-1]
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/byecode/pythonLearn.git
git@gitee.com:byecode/pythonLearn.git
byecode
pythonLearn
pythonLearn
master

搜索帮助