当前位置:网站首页>剑指 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();
}
}
边栏推荐
- 遊戲思考15:全區全服和分區分服的思考
- Construction and maintenance of business websites [15]
- 成功实现边缘编码需要了解的六大经验教训
- 【视频】马尔可夫链原理可视化解释与R语言区制转换MRS实例|数据分享
- Matlab uses resample to complete resampling
- np.where 和 torch.where 用法
- new和malloc的区别
- Volume compression, decompression
- MATLAB realizes voice signal resampling and normalization, and plays the comparison effect
- Android: the kotlin language uses grendao3, a cross platform app development framework
猜你喜欢
Medical management system (C language course for freshmen)
leetcode2305. 公平分发饼干(中等,周赛,状压dp)
Self drawing of menu items and CListBox items
What are the skills of spot gold analysis?
Using tabbar in wechat applet
Convolutional neural network (including code and corresponding diagram)
城市选择器组件实现原理
基于SSM实现微博系统
It's already 30. Can you learn programming from scratch?
[技术发展-21]:网络与通信技术的应用与发展快速概览-1- 互联网网络技术
随机推荐
2022 Q2 - 提升技能的技巧总结
How to use a product to promote "brand thrill"?
Parted command
TSINGSEE青犀平台如何实现同一节点同时播放多个视频?
Five skills of adding audio codec to embedded system
Android: the kotlin language uses grendao3, a cross platform app development framework
Another programmer "deleted the library and ran away", deleted the code of the retail platform, and was sentenced to 10 months
* and & symbols in C language
【C#】使用正则校验内容
分卷压缩,解压
MATLAB realizes voice signal resampling and normalization, and plays the comparison effect
479. Additive binary tree (interval DP on the tree)
Implementation of Weibo system based on SSM
Based on configured schedule, the given trigger will never fire
Quatre stratégies de base pour migrer la charge de travail de l'informatique en nuage
[Floyd] post disaster reconstruction
MySQL中一条SQL是怎么执行的
大学的知识是否学而无用、过时?
Réseau neuronal convolutif (y compris le Code et l'illustration correspondante)
基于SSM实现微博系统