当前位置:网站首页>剑指 Offer 31. 栈的压入、弹出序列
剑指 Offer 31. 栈的压入、弹出序列
2022-07-02 01:54:00 【Yake1965】
剑指 Offer 31. 栈的压入、弹出序列
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();
}
}
边栏推荐
- Niuke - Huawei question bank (51~60)
- Android: how can golden nine and silver ten squeeze into the first-line big factories from small and medium-sized enterprises? The depth of interview questions in large factories
- Learn about servlets
- [Floyd] post disaster reconstruction
- Redis有序集合如何使用
- Construction and maintenance of business websites [14]
- Implementation principle of city selector component
- Openssl3.0 learning XXI provider encoder
- TSINGSEE青犀平台如何实现同一节点同时播放多个视频?
- 【LeetCode 43】236. The nearest common ancestor of binary tree
猜你喜欢

开发那些事儿:如何利用Go单例模式保障流媒体高并发的安全性?

leetcode373. 查找和最小的 K 对数字(中等)

Redis环境搭建和使用的方法

matlab 实现语音信号重采样和归一化,并播放比对效果

leetcode2310. 个位数字为 K 的整数之和(中等,周赛)
![Private project practice sharing [Yugong series] February 2022 U3D full stack class 009 unity object creation](/img/eb/b1382428d6578b8561d7fcc1a2a5cd.jpg)
Private project practice sharing [Yugong series] February 2022 U3D full stack class 009 unity object creation

Memorabilia of domestic database in June 2022

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

成功实现边缘编码需要了解的六大经验教训

The concepts and differences between MySQL stored procedures and stored functions, as well as how to create them, the role of delimiter, the viewing, modification, deletion of stored procedures and fu
随机推荐
企业应该选择无服务器计算吗?
leetcode2305. 公平分发饼干(中等,周赛,状压dp)
如何远程、在线调试app?
Selection of field types for creating tables in MySQL database
正则表达式学习笔记
Logging only errors to the console Set system property ‘log4j2. debug‘ to sh
matlab 使用 audioread 、 sound 读取和播放 wav 文件
Exception handling of class C in yyds dry goods inventory
基于SSM实现微博系统
1222. Password dropping (interval DP, bracket matching)
C language 3-7 daffodils (enhanced version)
Matlab uses audioread and sound to read and play WAV files
New news, Wuhan Yangluo international port, filled with black technology, refreshes your understanding of the port
Redis环境搭建和使用的方法
Construction and maintenance of business websites [13]
Construction and maintenance of business websites [15]
Makefile simple induction
开发那些事儿:如何利用Go单例模式保障流媒体高并发的安全性?
Quatre stratégies de base pour migrer la charge de travail de l'informatique en nuage
10 minutes to get started quickly composition API (setup syntax sugar writing method)