当前位置:网站首页>Sword finger offer 30 Stack containing min function
Sword finger offer 30 Stack containing min function
2022-07-03 19:47:00 【Follow the road to the end】
Defines the data structure of the stack , Please implement a in this type that can get the minimum elements of the stack min The function is in the stack , call min、push And pop The time complexity of O(1).
class MinStack {
constructor () {
// Store stack data
this.data = []
}
// Stack method
push (item) {
this.data.push(item)
}
// Stack method
pop () {
this.data.pop()
}
top () {
return this.data[this.data.length - 1]
}
min () {
return Math.min(...this.data)
}
}1
边栏推荐
- Chapter 1: sum of three factorials, graph point scanning
- 2022 - 06 - 30 networker Advanced (XIV) Routing Policy Matching Tool [ACL, IP prefix list] and policy tool [Filter Policy]
- 第一章: 舍罕王失算
- Use unique_ PTR forward declaration? [repetition] - forward declaration with unique_ ptr? [duplicate]
- Vscode reports an error according to the go plug-in go get connectex: a connection attempt failed because the connected party did not pro
- Comments on flowable source code (37) asynchronous job processor
- Luogu-p1107 [bjwc2008] Lei Tao's kitten
- 2022-06-25 网工进阶(十一)IS-IS-三大表(邻居表、路由表、链路状态数据库表)、LSP、CSNP、PSNP、LSP的同步过程
- 2022-07-02 advanced network engineering (XV) routing policy - route policy feature, policy based routing, MQC (modular QoS command line)
- Read the paper glodyne global topology preserving dynamic network embedding
猜你喜欢

FAQs for datawhale learning!

Chapter 1: recursively find the factorial n of n!

第一章:喝汽水,阶梯电费计算,阶梯电费计算函数,个人所税,求解平方根不等式,简化求解平方根不等式,求解调和级数不等式,解不等式:d<1+1/2-1/3+1/4+1/5-1/6+..士1/n

2022.2.14 Li Kou - daily question - single element in an ordered array

2022-07-02 网工进阶(十五)路由策略-Route-Policy特性、策略路由(Policy-Based Routing)、MQC(模块化QoS命令行)

NFT without IPFs and completely on the chain?

第二章:求a,b的最大公约与最小公倍数经典求解,求a,b的最大公约与最小公倍数常规求解,求n个正整数的的最大公约与最小公倍数

2022-07-02 advanced network engineering (XV) routing policy - route policy feature, policy based routing, MQC (modular QoS command line)

Chapitre 1: le roi de shehan a mal calculé

Chapter 2: find the box array, complete number in the specified interval, and improve the complete number in the specified interval
随机推荐
BUUCTF
Zhang Fei hardware 90 day learning notes - personal records on day 2, please see my personal profile / homepage for the complete
What is the content of game modeling
Day11 - my page, user information acquisition, modification and channel interface
Chapitre 1: le roi de shehan a mal calculé
2022-06-28 advanced network engineering (XIII) IS-IS route filtering, route summary, authentication, factors affecting the establishment of Isis neighbor relations, other commands and characteristics
Teach you how to quickly recover data by deleting recycle bin files by mistake
Geek Daily: the system of monitoring employees' turnover intention has been deeply convinced off the shelves; The meta universe app of wechat and QQ was actively removed from the shelves; IntelliJ pla
Microsoft: the 12th generation core processor needs to be upgraded to win11 to give full play to its maximum performance
Realize user registration and login
Kubernetes cluster builds efk log collection platform
Web Security (VII) specific process of authentication with session cookie scheme
Part 27 supplement (27) buttons of QML basic elements
WPF format datetime in TextBlock- WPF format DateTime in TextBlock?
Gym welcomes the first complete environmental document, which makes it easier to get started with intensive learning!
Meso tetra [P - (p-n-carbazole benzylidene imino)] phenylporphyrin (tcipp) /eu (tcipp) [pc( α- 2-oc8h17) 4] and euh (tcipp) [pc (a-2-oc8h17) 4] supplied by Qiyue
02 -- QT OpenGL drawing triangle
Day10 ---- 强制登录, token刷新与jwt禁用
第一章: 舍罕王失算
2022-06-27 网工进阶(十二)IS-IS-开销类型、开销计算、LSP的处理机制、路由撤销、路由渗透