155.最小堆叠
最编程
2024-10-05 07:14:46
...
class MinStack(object):
def __init__(self):
self.stack=[]
def push(self, val):
"""
:type val: int
:rtype: None
"""
self.stack.append(val)
def pop(self):
"""
:rtype: None
"""
self.stack.pop()
def top(self):
"""
:rtype: int
"""
return self.stack[-1]
def getMin(self):
"""
:rtype: int
"""
return min(self.stack)
# Your MinStack object will be instantiated and called as such:
# obj = MinStack()
# obj.push(val)
# obj.pop()
# param_3 = obj.top()
# param_4 = obj.getMin()
推荐阅读
-
155.最小堆叠
-
立法会记录 1:查找旋转数组的最小值,确定旋转数组中是否存在给定元素 33. 查找旋转排序数组
-
C++ | Leetcode C++ 问题解决 440 字典序列的第 K 个最小数 - 问题解决:
-
Golang | Leetcode Golang 问题解决程序 第 440 题 字典序列的第 K 个最小数 - 问题解决程序:
-
二叉搜索树中的第 k 个最小元素 - 输入:根 = [5,3,6,2,4,null,null,1],k = 3 输出: 33 提示
-
一文让你彻底搞懂最小二乘法(超详细推导)
-
通过手写大顶堆和使用优先级队列进行比较,找出最小的K个数
-
数据结构与算法--排序算法:堆排序 最大堆(大顶堆)和 最小堆(小顶堆)详解
-
最小的K个数(手写大顶堆和用优先级队列比较)
-
创作一个全屏显示的QT软件,最小化后再次打开时不再保持全屏模式