当前位置:网站首页>剑指 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();
}
}
边栏推荐
- Which is a good Bluetooth headset of about 300? 2022 high cost performance Bluetooth headset inventory
- 现货黄金分析的技巧有什么呢?
- Based on configured schedule, the given trigger will never fire
- 479. Additive binary tree (interval DP on the tree)
- 电子协会 C语言 1级 32、计算2的幂
- What is AQS and its principle
- Post infiltration flow encryption
- 迁移云计算工作负载的四个基本策略
- TSINGSEE青犀平台如何实现同一节点同时播放多个视频?
- Number of palindromes in C language (leetcode)
猜你喜欢

分卷压缩,解压
![[Maya] the error of importing Maya into Metahuman](/img/46/46bd1c2d507c9e48ef8c066c54231d.jpg)
[Maya] the error of importing Maya into Metahuman

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

迁移云计算工作负载的四个基本策略

MATLAB realizes voice signal resampling and normalization, and plays the comparison effect

Four basic strategies for migrating cloud computing workloads

跨域?同源?一次搞懂什么是跨域

What is AQS and its principle

Redis有序集合如何使用

What are the affordable Bluetooth headsets? Student party parity Bluetooth headset recommendation
随机推荐
Redis有序集合如何使用
如何用一款产品推动「品牌的惊险一跃」?
Design and implementation of key value storage engine based on LSM tree
This is the report that leaders like! Learn dynamic visual charts, promotion and salary increase are indispensable
Memorabilia of domestic database in June 2022
321. Chessboard segmentation (2D interval DP)
Modeling essays series 124 a simple coding method
迁移云计算工作负载的四个基本策略
golang---锁
Software No.1
[question] - why is optical flow not good for static scenes
Experimental reproduction of variable image compression with a scale hyperprior
2022 Q2 - Summary of skills to improve skills
MySQL中一条SQL是怎么执行的
uTools
Bat Android Engineer interview process analysis + restore the most authentic and complete first-line company interview questions
* and & symbols in C language
开发那些事儿:如何利用Go单例模式保障流媒体高并发的安全性?
2022 Q2 - résumé des compétences pour améliorer les compétences
自动浏览拼多多商品