当前位置:网站首页>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
边栏推荐
- 6. Data agent object Defineproperty method
- WPF format datetime in TextBlock- WPF format DateTime in TextBlock?
- Detailed explanation of shuttle unity interworking principle
- Rd file name conflict when extending a S4 method of some other package
- Class loading process
- 03 -- QT OpenGL EBO draw triangle
- 第一章:拓广同码小数和s(d, n)
- Pecan - route
- How to check the permission to write to a directory or file- How do you check for permissions to write to a directory or file?
- 2022 Xinjiang latest road transportation safety officer simulation examination questions and answers
猜你喜欢
HCIA-USG Security Policy
2022 Xinjiang latest road transportation safety officer simulation examination questions and answers
Sentinel source code analysis part II - sentinel dashboard console startup and configuration
2022-06-30 网工进阶(十四)路由策略-匹配工具【ACL、IP-Prefix List】、策略工具【Filter-Policy】
FAQs for datawhale learning!
第二章:求a,b的最大公约与最小公倍数经典求解,求a,b的最大公约与最小公倍数常规求解,求n个正整数的的最大公约与最小公倍数
PR 2021 quick start tutorial, material import and management
Common text labels
第一章:求同吗小数和s(d, n)
If the warehouse management communication is not in place, what problems will occur?
随机推荐
The space of C disk is insufficient, and the computer becomes stuck. Quickly expand the capacity of C disk to make the system more smooth
10 smart contract developer tools that miss and lose
Chapter 20: y= sin (x) /x, rambling coordinate system calculation, y= sin (x) /x with profile graphics, Olympic rings, ball rolling and bouncing, water display, rectangular optimization cutting, R que
Teach you how to quickly recover data by deleting recycle bin files by mistake
Use of aggregate functions
unittest框架基本使用
Point cloud data denoising
2022-06-27 网工进阶(十二)IS-IS-开销类型、开销计算、LSP的处理机制、路由撤销、路由渗透
Chapter 1: simplify the same code decimal sum s (D, n)
Don't be afraid of no foundation. Zero foundation doesn't need any technology to reinstall the computer system
BUUCTF
Titles can only be retrieved in PHP via curl - header only retrieval in PHP via curl
PR notes:
Xctf attack and defense world crypto advanced area best_ rsa
论文阅读 GloDyNE Global Topology Preserving Dynamic Network Embedding
Part 28 supplement (XXVIII) busyindicator (waiting for elements)
BOC protected phenylalanine zinc porphyrin (Zn · TAPP Phe BOC) / iron porphyrin (Fe · TAPP Phe BOC) / nickel porphyrin (Ni · TAPP Phe BOC) / manganese porphyrin (Mn · TAPP Phe BOC) Qiyue Keke
Redis master-slave synchronization, clustering, persistence
I study database at station B (4): DQL
04 -- QT OpenGL two sets of shaders draw two triangles