当前位置:网站首页>[sword finger offer] 42 Stack push in and pop-up sequence
[sword finger offer] 42 Stack push in and pop-up sequence
2022-07-07 10:15:00 【percation】
The first question of rehabilitation training , I deeply feel that there is another dish , It's already very delicious
class Solution {
public:
bool isPopOrder(vector<int> pushV,vector<int> popV) {
if(popV.size() != pushV.size()) return false;
stack<int> s;
int idx = 0;
for(int i = 0; i < pushV.size(); i++){
s.push(pushV[i]);
while(!s.empty() && (s.top() == popV[idx])){
s.pop();
idx++;
}
}
if(s.empty() == true) return true;
return false;
}
};
边栏推荐
- 一文讲解单片机、ARM、MUC、DSP、FPGA、嵌入式错综复杂的关系
- There is a problem using Chinese characters in SQL. Who has encountered it? Such as value & lt; & gt;` None`
- 【acwing】786. 第k个数
- .NET配置系统
- SolidWorks工程图中添加中心线和中心符号线的办法
- conda离线创建虚拟环境
- Chris Lattner, père de llvm: Pourquoi reconstruire le logiciel d'infrastructure ai
- C logging method
- request对象对请求体,请求头参数的解析
- Analyze Android event distribution mechanism according to popular interview questions (I)
猜你喜欢

STM32 ADC and DMA

The physical meaning of imaginary number J

Postman interface test V

ORM模型--数据记录的创建操作,查询操作

LeetCode 练习——113. 路径总和 II

STM32基础知识—内存映射

Appx代码签名指南

LLVM之父Chris Lattner:為什麼我們要重建AI基礎設施軟件

Delete a record in the table in pl/sql by mistake, and the recovery method

Use of JSON extractor originals in JMeter
随机推荐
Why does the starting service report an error when installing MySQL? (operating system Windows)
A wave of open source notebooks is coming
Future development blueprint of agriculture and animal husbandry -- vertical agriculture + artificial meat
Google Colab装载Google Drive(Google Colab中使用Google Drive)
UnityWebRequest基础使用之下载文本、图片、AB包
Pdf document signature Guide
Methods of adding centerlines and centerlines in SolidWorks drawings
ES类和对象、原型
Es classes and objects, prototypes
IPv4套接字地址结构
Apprentissage avancé des fonctions en es6
对存储过程进行加密和解密(SQL 2008/SQL 2012)
C logging method
【学习笔记-李宏毅】GAN(生成对抗网络)全系列(一)
Guid主键
Word自动生成目录的方法
网上可以开炒股账户吗安全吗
Guide de signature du Code Appx
phpcms实现PC网站接入微信Native支付
Writing file types generated by C language
