当前位置:网站首页>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();
}
}
边栏推荐
- Open that kind of construction document
- 电子协会 C语言 1级 32、计算2的幂
- Niuke - Huawei question bank (51~60)
- 剑指 Offer 47. 礼物的最大价值
- 【LeetCode 43】236. The nearest common ancestor of binary tree
- Selection of field types for creating tables in MySQL database
- Redis环境搭建和使用的方法
- Is the knowledge of University useless and outdated?
- Four basic strategies for migrating cloud computing workloads
- Matlab uses audioread and sound to read and play WAV files
猜你喜欢

花一个星期时间呕心沥血整理出高频软件测试/自动化测试面试题和答案

From January 11, 2007 to January 11, 2022, I have been in SAP Chengdu Research Institute for 15 years

What are the skills of spot gold analysis?

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

RTL8189FS如何关闭Debug信息

Cross domain? Homology? Understand what is cross domain at once

Four basic strategies for migrating cloud computing workloads

How to use redis ordered collection

matlab 实现语音信号重采样和归一化,并播放比对效果

MySQL view concept, create view, view, modify view, delete view
随机推荐
Architecture evolution from MVC to DDD
剑指 Offer 31. 栈的压入、弹出序列
分卷压缩,解压
321. Chessboard segmentation (2D interval DP)
开发工具创新升级,鲲鹏推进计算产业“竹林”式生长
电子协会 C语言 1级 32、计算2的幂
Cross domain? Homology? Understand what is cross domain at once
MySQL constraints and multi table query example analysis
城市选择器组件实现原理
leetcode2309. The best English letters with both upper and lower case (simple, weekly)
Niuke - Huawei question bank (51~60)
Opengauss database backup and recovery guide
leetcode2310. The one digit number is the sum of integers of K (medium, weekly)
Bat Android Engineer interview process analysis + restore the most authentic and complete first-line company interview questions
matlab 使用 audioread 、 sound 读取和播放 wav 文件
[Video] visual interpretation of Markov chain principle and Mrs example of R language region conversion | data sharing
[technology development -21]: rapid overview of the application and development of network and communication technology -1- Internet Network Technology
How to solve MySQL master-slave delay problem
Matlab uses resample to complete resampling
【视频】马尔可夫链原理可视化解释与R语言区制转换MRS实例|数据分享