当前位置:网站首页>Sword finger offer 31 Stack push in and pop-up sequence
Sword finger offer 31 Stack push in and pop-up sequence
2022-07-02 02:00:00 【Yake1965】
The finger of the sword Offer 31. Pressure into the stack 、 Pop-up sequence
class Solution {
public boolean validateStackSequences(int[] pushed, int[] popped) {
Deque<Integer> q = new LinkedList<>();
int idx = 0;
for(int x : pushed){
q.push(x);
while(!q.isEmpty() && q.peek() == popped[idx]){
q.pop();
idx++;
}
}
return q.isEmpty();
}
}
边栏推荐
- What is the MySQL column to row function
- Number of palindromes in C language (leetcode)
- 剑指 Offer 47. 礼物的最大价值
- matlab 使用 resample 完成重采样
- Deep learning: a solution to over fitting in deep neural networks
- What is AQS and its principle
- New news, Wuhan Yangluo international port, filled with black technology, refreshes your understanding of the port
- The role of artificial intelligence in network security
- 正则表达式学习笔记
- With the innovation and upgrading of development tools, Kunpeng promotes the "bamboo forest" growth of the computing industry
猜你喜欢
![[question] - why is optical flow not good for static scenes](/img/8d/2cf6f582bc58cc2985f50e3f85f334.jpg)
[question] - why is optical flow not good for static scenes

1069. Division of convex polygons (thinking, interval DP)

How to execute an SQL in MySQL

Word search applet design report based on cloud development +ppt+ project source code + demonstration video

What style of Bluetooth headset is easy to use? High quality Bluetooth headset ranking

How can the tsingsee Qingxi platform play multiple videos at the same time on the same node?

Opengauss database backup and recovery guide

The concept, function, characteristics, creation and deletion of MySQL constraints

人工智能在网络安全中的作用

leetcode2312. Selling wood blocks (difficult, weekly race)
随机推荐
Selection of field types for creating tables in MySQL database
Matlab uses resample to complete resampling
Implementation principle of city selector component
MySQL constraints and multi table query example analysis
【深度学习】infomap 人脸聚类 facecluster
医药管理系统(大一下C语言课设)
开发那些事儿:如何利用Go单例模式保障流媒体高并发的安全性?
Matlab uses audiorecorder and recordblocking to record sound, play to play sound, and audiobook to save sound
5g/4g pole gateway_ Smart pole gateway
AR增强现实可应用的场景
Is the knowledge of University useless and outdated?
new和malloc的区别
Matlab uses audioread and sound to read and play WAV files
MySQL view concept, create view, view, modify view, delete view
Golang lock
Ks006 student achievement management system based on SSM
自动浏览拼多多商品
1069. Division of convex polygons (thinking, interval DP)
leetcode2312. 卖木头块(困难,周赛)
分卷压缩,解压