当前位置:网站首页>[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、嵌入式错综复杂的关系
- ISP、IAP、ICP、JTAG、SWD的编程特点
- Chris LATTNER, the father of llvm: why should we rebuild AI infrastructure software
- ES6中的函数进阶学习
- ES6中的原型对象
- Inno Setup 打包及签名指南
- ORM--分组查询,聚合查询,查询集QuerySet对象特性
- arcgis操作:dwg数据转为shp数据
- Google colab loads Google drive (Google drive is used in Google colab)
- ORM -- query type, association query
猜你喜欢
“十二星座女神降临”全新活动推出
ORM -- logical relation and & or; Sort operation, update record operation, delete record operation
A wave of open source notebooks is coming
request对象对请求体,请求头参数的解析
ES6中的原型对象
Programming features of ISP, IAP, ICP, JTAG and SWD
Internship log - day07
Appx代码签名指南
VS Code指定扩展安装位置
Postman interface test VII
随机推荐
“十二星座女神降临”全新活动推出
C logging method
Introduction to automated testing framework
Delete a record in the table in pl/sql by mistake, and the recovery method
ArcGIS operation: converting DWG data to SHP data
Official media attention! The list of top 100 domestic digital collection platforms was released, and the industry accelerated the healthy development of compliance
Pytest learning - dayone
arcgis操作:dwg数据转为shp数据
电表远程抄表拉合闸操作命令指令
Three years after graduation
Do you have a boss to help look at this error report and what troubleshooting ideas are there? Oracle CDC 2.2.1 flick 1.14.4
【学习笔记-李宏毅】GAN(生成对抗网络)全系列(一)
STM32产品介绍
Using keras in tensorflow to build convolutional neural network
AI moves from perception to intelligent cognition
Weekly recommended short videos: what are the functions of L2 that we often use in daily life?
Internship log - day04
Fiddler break point
Wallys/IPQ6010 (IPQ6018 FAMILY) EMBEDDED BOARD WITH ON-BOARD WIFI DUAL BAND DUAL CONCURRENT
STM32 ADC and DMA