当前位置:网站首页>Sword finger offer (twenty): stack containing min function
Sword finger offer (twenty): stack containing min function
2022-07-26 10:46:00 【Konstanch】
solution 1: about python Speaking of , Stack is used list Realized !
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]
边栏推荐
猜你喜欢

2021-08-12 function recursion_ Learn C language with brother Peng

232.用栈实现队列

Flutter编译报错 version of NDK matched the requested version 21.0.6113669. Versions available locally: 2

Issue 6: which mainstream programming language should college students choose

软件测试综述之软件测试的背景、实质、软件开发的过程

在神州IV开发板上成功移植STemWin V5.22

Kali view IP address

Issue 7: how do you choose between curling up and lying flat

RT-Thread 学习笔记(五)---编辑、下载、调试程序

RT thread learning notes (VI) -- start the elmfat file system based on SPI flash (Part 1)
随机推荐
剑指Offer(五):用两个栈实现队列
MFC中0x003b66c3 处有未经处理的异常: 0xC000041D: 用户回调期间遇到未经处理的异常
RT thread learning notes (I) -- configure RT thread development environment
RT thread learning notes (V) -- edit, download and debug programs
智能合约dapp系统开发流程技术
7-25 0-1背包 (50分)
RT thread learning notes (VII) -- open the elmfat file system based on SPI flash (middle)
[machine learning notes] [style transfer] deeplearning ai course4 4th week programming(tensorflow2)
PLC与伺服电机连接
27.移除元素
2021-08-12函数递归_和鹏哥学习C语言
Pengge C language lesson 4 (3)
MySQL quicklearn-2021-09-01
c结构体中定义的成员指针赋值与结构体指针作为成员函数参数的使用
RT thread learning notes (VI) -- start the elmfat file system based on SPI flash (Part 1)
Issue 6: which mainstream programming language should college students choose
很多人都不清楚自己找的是Kanban软件还是看板软件
Minesweeping Pro version 2021-08-19
[leetcode daily question 2021/2/18] [detailed explanation] minimum number of turns of 995. K continuous bits
Zongzi battle - guess who can win