当前位置:网站首页>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();
}
}
边栏推荐
- Develop those things: how to use go singleton mode to ensure the security of high concurrency of streaming media?
- Volume compression, decompression
- Open那啥的搭建文档
- Automatically browse pinduoduo products
- 大学的知识是否学而无用、过时?
- Four basic strategies for migrating cloud computing workloads
- Design and implementation of key value storage engine based on LSM tree
- 牛客网——华为题库(51~60)
- MySQL约束与多表查询实例分析
- leetcode2311. Longest binary subsequence less than or equal to K (medium, weekly)
猜你喜欢
AR增强现实可应用的场景
Learn basic K-line diagram knowledge in three minutes
Pyldavis installation and use | attributeerror: module 'pyldavis' has no attribute' gensim '| visual results are exported as separate web pages
1069. Division of convex polygons (thinking, interval DP)
Should enterprises choose server free computing?
leetcode2310. 个位数字为 K 的整数之和(中等,周赛)
Architecture evolution from MVC to DDD
leetcode2311. Longest binary subsequence less than or equal to K (medium, weekly)
Implementation of Weibo system based on SSM
Discussion on the idea of platform construction
随机推荐
How to solve MySQL master-slave delay problem
Automatically browse pinduoduo products
What are the necessary things for students to start school? Ranking list of Bluetooth headsets with good sound quality
Matlab uses resample to complete resampling
Failed to transform file 'xxx' to match attributes
Construction and maintenance of business websites [14]
leetcode2310. The one digit number is the sum of integers of K (medium, weekly)
Electronic Society C language level 1 32, calculate the power of 2
Three core problems of concurrent programming
MySQL view concept, create view, view, modify view, delete view
leetcode373. 查找和最小的 K 对数字(中等)
自动浏览拼多多商品
[Video] visual interpretation of Markov chain principle and Mrs example of R language region conversion | data sharing
Discussion on the idea of platform construction
Opengauss database backup and recovery guide
【毕业季】研究生学长分享怎样让本科更有意义
城市选择器组件实现原理
Makefile simple induction
Exception handling of class C in yyds dry goods inventory
Ar Augmented Reality applicable scenarios