当前位置:网站首页>剑指 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();
}
}
边栏推荐
- [Video] Markov chain Monte Carlo method MCMC principle and R language implementation | data sharing
- 2022 Q2 - Summary of skills to improve skills
- Four basic strategies for migrating cloud computing workloads
- Bat Android Engineer interview process analysis + restore the most authentic and complete first-line company interview questions
- SQLite 3 of embedded database
- 1069. Division of convex polygons (thinking, interval DP)
- Self drawing of menu items and CListBox items
- 机器学习基本概念
- "C language programming", 4th Edition, edited by he Qinming and Yan Hui, after class exercise answers Chapter 3 branch structure Exercise 3
- new和malloc的区别
猜你喜欢

Which is a good Bluetooth headset of about 300? 2022 high cost performance Bluetooth headset inventory

Develop those things: how to use go singleton mode to ensure the security of high concurrency of streaming media?

ES6 new method of string

如何用一款产品推动「品牌的惊险一跃」?

Introduction to ffmpeg Lib

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

1222. Password dropping (interval DP, bracket matching)

The technology boss is ready, and the topic of position C is up to you

医药管理系统(大一下C语言课设)

遊戲思考15:全區全服和分區分服的思考
随机推荐
如何用一款产品推动「品牌的惊险一跃」?
Using mongodb in laravel
Learn basic K-line diagram knowledge in three minutes
ES6 new method of string
Learn about servlets
Five skills of adding audio codec to embedded system
Bat Android Engineer interview process analysis + restore the most authentic and complete first-line company interview questions
人工智能在网络安全中的作用
10 minutes to get started quickly composition API (setup syntax sugar writing method)
Opengauss database backup and recovery guide
How can the tsingsee Qingxi platform play multiple videos at the same time on the same node?
分卷压缩,解压
The role of artificial intelligence in network security
mysql列转行函数指的是什么
并发编程的三大核心问题
[Video] visual interpretation of Markov chain principle and Mrs example of R language region conversion | data sharing
2022 Q2 - Summary of skills to improve skills
【视频】马尔可夫链蒙特卡罗方法MCMC原理与R语言实现|数据分享
With the innovation and upgrading of development tools, Kunpeng promotes the "bamboo forest" growth of the computing industry
Makefile simple induction