当前位置:网站首页>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
边栏推荐
- Native table - scroll - merge function
- 第一章: 舍罕王失算
- Octopus online ecological chain tour Atocha protocol received near grant worth $50000
- 04 -- QT OpenGL two sets of shaders draw two triangles
- Chapter 2: find the number of daffodils based on decomposition, find the number of daffodils based on combination, find the conformal number in [x, y], explore the n-bit conformal number, recursively
- 2022-06-30 advanced network engineering (XIV) routing strategy - matching tools [ACL, IP prefix list], policy tools [filter policy]
- Use unique_ PTR forward declaration? [repetition] - forward declaration with unique_ ptr? [duplicate]
- P3402 persistent and searchable
- Leetcode 1189. Maximum number of balloons (special character count)
- Comments on flowable source code (37) asynchronous job processor
猜你喜欢
What is the content of game modeling
第二十章:y= sin(x)/x,漫步坐标系计算,y= sin(x)/x 带廓幅图形,奥运五环,小球滚动与弹跳,流水显示,矩形优化裁剪,r个皇后全控nxn棋盘
04 -- QT OpenGL two sets of shaders draw two triangles
05 -- QT OpenGL draw cube uniform
The necessity of lean production and management in sheet metal industry
03 -- QT OpenGL EBO draw triangle
BOC protected tryptophan porphyrin compound (TAPP Trp BOC) Pink Solid 162.8mg supply - Qiyue supply
How to improve data security by renting servers in Hong Kong
第二章:基于分解的求水仙花数,基于组合的求水仙花数, 兰德尔数,求[x,y]内的守形数,探求n位守形数,递推探索n位逐位整除数
2022-06-27 advanced network engineering (XII) IS-IS overhead type, overhead calculation, LSP processing mechanism, route revocation, route penetration
随机推荐
P3402 persistent and searchable
Xctf attack and defense world crypto master advanced area olddriver
The simplicity of laravel
2022-06-27 网工进阶(十二)IS-IS-开销类型、开销计算、LSP的处理机制、路由撤销、路由渗透
4. Data splitting of Flink real-time project
Teach you how to quickly recover data by deleting recycle bin files by mistake
2022-06-25 advanced network engineering (XI) IS-IS synchronization process of three tables (neighbor table, routing table, link state database table), LSP, cSNP, psnp, LSP
论文阅读 GloDyNE Global Topology Preserving Dynamic Network Embedding
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
Cesiumjs 2022 ^ source code interpretation [7] - Analysis of the request and loading process of 3dfiles
February 14-20, 2022 (osgear source code debugging +ue4 video +ogremain source code transcription)
Xctf attack and defense world crypto advanced area best_ rsa
P1891 crazy LCM (Euler function)
5- (4-nitrophenyl) - 10,15,20-triphenylporphyrin ntpph2/ntppzn/ntppmn/ntppfe/ntppni/ntppcu/ntppcd/ntppco and other metal complexes
Microsoft: the 12th generation core processor needs to be upgraded to win11 to give full play to its maximum performance
2022-07-02 网工进阶(十五)路由策略-Route-Policy特性、策略路由(Policy-Based Routing)、MQC(模块化QoS命令行)
第二章:求a,b的最大公约与最小公倍数经典求解,求a,b的最大公约与最小公倍数常规求解,求n个正整数的的最大公约与最小公倍数
PR notes:
BOC protected alanine zinc porphyrin Zn · TAPP ala BOC / alanine zinc porphyrin Zn · TAPP ala BOC / alanine zinc porphyrin Zn · TAPP ala BOC / alanine zinc porphyrin Zn · TAPP ala BOC supplied by Qiyu
02 -- QT OpenGL drawing triangle