当前位置:网站首页>剑指Offer(二十):包含min函数的栈
剑指Offer(二十):包含min函数的栈
2022-07-26 10:36:00 【康斯坦奇】
解法1:对于python来讲,栈就是用list实现的!
class Solution:
def __init__(self):
self.stack = []
self.assist = []
def push(self,node):
min = self.min()
if not min or node < min:
self.assist.append(node)
else:
self.assist.append(min)
self.stack.append(node)
def pop(self):
if self.stack:
self.assist.pop()
return self.stack.pop()
def top(self):
if self.stack:
return self.stack[-1]
def min(self):
if self.assist:
return self.assist[-1]
边栏推荐
- Navicat15 MySQL (centos7) connected to local virtual machine
- 图片随手机水平移动-陀螺仪。360度设置条件
- js 获得当前时间,时间与时间戳的转换
- Centos8 (liunx) deploying WTM (asp.net 5) using PgSQL
- cavans实现静态滚动弹幕
- Redis Docker实例与数据结构
- Our Web3 entrepreneurship project is yellow
- 使用Geoprocessor 工具
- .net operation redis sorted set ordered set
- Using native JS to realize custom scroll bar (click to reach, drag to reach)
猜你喜欢
![[Halcon vision] array](/img/29/905d93795a24538fded18d2d377e52.png)
[Halcon vision] array

Comparison of packet capturing tools fiddler and Wireshark
![[Halcon vision] morphological corrosion](/img/f9/f01dd3340824ff28c84cf7bb52882e.png)
[Halcon vision] morphological corrosion

uniapp使用简单方法signalR(仅用于web调试,无法打包app)
![[Halcon vision] threshold segmentation](/img/1c/e2463a796f99804a55680b69e714a6.png)
[Halcon vision] threshold segmentation

js 获得当前时间,时间与时间戳的转换
![[leetcode每日一题2021/2/14]765. 情侣牵手](/img/be/8639a05c733638bf0b3fdeb11abccf.png)
[leetcode每日一题2021/2/14]765. 情侣牵手
![[Halcon vision] affine transformation](/img/f1/32284c71e78e6eea390fdb6058ba0f.png)
[Halcon vision] affine transformation

hx711 数据波动大的问题

抽象工厂及其改进示例
随机推荐
Our Web3 entrepreneurship project is yellow
[Halcon vision] threshold segmentation
What if MySQL can't get in
常见的类(了解)
12 复制对象时勿忘其每一个成分
【机器学习小记】【风格迁移】deeplearning.ai course4 4th week programming(tensorflow2)
Analyze the hybrid construction objects in JS in detail (construction plus attributes, prototype plus methods)
[leetcode每日一题2021/8/30]528. 按权重随机选择【中等】
json_ object_ put: Assertion `jso->_ ref_ count > 0‘ failed. Aborted (core dumped)
2022/07/25 ------ arrangement of strings
js下载文件,FileSaver.js导出txt、excel文件
[Halcon vision] image filtering
[leetcode每日一题2021/2/18]【详解】995. K 连续位的最小翻转次数
The problem of large fluctuation of hx711 data
C语言回调函数
第8期:云原生—— 大学生职场小白该如何学
文案秘籍七步曲至----文献团队协作管理
algorithm
Issue 8: cloud native -- how should college students learn in the workplace
将json文件中数组转换为struct