当前位置:网站首页>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();
}
}
边栏推荐
- 如何用一款产品推动「品牌的惊险一跃」?
- 花一个星期时间呕心沥血整理出高频软件测试/自动化测试面试题和答案
- How to build and use redis environment
- 剑指 Offer 29. 顺时针打印矩阵
- How to execute an SQL in MySQL
- What style of Bluetooth headset is easy to use? High quality Bluetooth headset ranking
- Electronic Association C language level 1 33, odd even number judgment
- 开发那些事儿:如何利用Go单例模式保障流媒体高并发的安全性?
- 成功实现边缘编码需要了解的六大经验教训
- Construction and maintenance of business websites [13]
猜你喜欢
MySQL主从延迟问题怎么解决
JMeter (II) - install the custom thread groups plug-in
跨域?同源?一次搞懂什么是跨域
PR second training
Another programmer "deleted the library and ran away", deleted the code of the retail platform, and was sentenced to 10 months
SQLite 3 of embedded database
This is the report that leaders like! Learn dynamic visual charts, promotion and salary increase are indispensable
How to execute an SQL in MySQL
MPLS experiment operation
如何远程、在线调试app?
随机推荐
VARIATIONAL IMAGE COMPRESSION WITH A SCALE HYPERPRIOR文献实验复现
Open那啥的搭建文档
Construction and maintenance of business websites [10]
Iterative unified writing method of binary tree
【LeetCode 43】236. The nearest common ancestor of binary tree
D discard the virtual recovery method
OpenCASCADE7.6编译
How does MySQL solve the problem of not releasing space after deleting a large amount of data
如何用一款产品推动「品牌的惊险一跃」?
Post infiltration flow encryption
Volume compression, decompression
电子协会 C语言 1级 32、计算2的幂
* and & symbols in C language
SAP ui5 beginner tutorial 20 - explanation of expression binding usage of SAP ui5
正则表达式学习笔记
2022 Q2 - 提昇技能的技巧總結
leetcode2310. 个位数字为 K 的整数之和(中等,周赛)
"C language programming", 4th Edition, edited by he Qinming and Yan Hui, after class exercise answers Chapter 3 branch structure
自动浏览拼多多商品
The difference between new and malloc