当前位置:网站首页>Jz30 stack containing min function
Jz30 stack containing min function
2022-07-21 16:36:00 【syc596】
JZ30 contain min Function of the stack
contain min Function of the stack _ Niuke Tiba _ Cattle from (nowcoder.com)
import java.util.*;
import java.util.Stack;
public class Solution {
Stack<Integer> st1=new Stack<>();// The data stack
Stack<Integer> st2=new Stack<>();// Smallest stack
public void push(int node) {
st1.push(node);
if(st2.isEmpty()||node<st2.peek()){
st2.push(node);
}else{
st2.push(st2.peek());
}
}
public void pop() {
st1.pop();
st2.pop();
}
public int top() {
return st1.peek();
}
public int min() {
return st2.peek();
}
}
边栏推荐
- Mohist patrol source code
- JZ32 从上往下打印二叉树
- Jz69 jumping steps
- 2022 Shandong vision prevention and control conference, China eye care products exhibition, Jinan myopia correction equipment exhibition
- I2C client Drive
- Esp8266 nodemcu -- use u8g2 library to light OLED
- js的可选链
- Calculate the centrifugal angle according to the center angle of the circle
- How to ensure data security while saving 30% disk space DB · insight
- C | file operation
猜你喜欢
In depth analysis: how chain 2+1 mode plays with investment attraction and drainage
Lora base station coverage
Cluster deployment of Apache Druid 0.22 real-time analysis database on CentOS 7
Dama Chapter 9 (document and content management)
Difference between service and systemctl / method of modifying path / a command to view IP address, gateway and DNS server
What preliminary work does the enterprise need to do to establish its own applet and app?
Dama Chapter 12 (metadata management)
Which is the best multilingual mall system? Comparison of three famous cross-border e-commerce manufacturers
專注跨境支付一體化服務 iPayLinks榮獲《財資》(The Asset)3A亞洲獎!
Dama Chapter 10 (reference data and master data)
随机推荐
Project summary: document management system
[super easy to understand competition questions] 2021 Sichuan University Student Program Design Competition
Using go TCP to realize simple online group chat function
Several stumbling blocks of it entrepreneurs
[dip/ implementation of simple digital image processing system] high score course design paper sharing
Translation of UAV intelligent coverage navigation based on DRL in complex geometric environments
平安证券是国企?开户安全嘛?
安装C3D v1.0
After graduation, the three people in beidatong dormitory went to foreign enterprises, state-owned enterprises and entrepreneurship respectively. What do they regret after 10 years
Dama Chapter 11 (data warehouse and business intelligence)
Dama Chapter 3 (Data Governance)
Cad2014 x64 debugging ARX
Signal integrity (SI) power integrity (PI) learning notes (xxx) power distribution network (II)
2022 eye care lamp exhibition, traditional Chinese medicine eye conditioning exhibition, Shandong eye health exhibition, China eye Expo
2022 the 5th China (Jinan) International Youth eye health industry exhibition was held in September
The middle-aged crisis in the Internet industry is the watershed of 35 years old
Get the current dimension style dimstyle
pip&conda 搜索包|查看可安装包版本
Dama summary (summary of data management)
Win64 driver kernel programming -30 Enumerating and deleting thread callbacks