当前位置:网站首页>【剑指Offer】42. 栈的压入、弹出序列
【剑指Offer】42. 栈的压入、弹出序列
2022-07-07 07:46:00 【percation】
康复训练第一题,深深地感觉又菜了,本来就很菜了
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;
}
};
边栏推荐
- ISP、IAP、ICP、JTAG、SWD的编程特点
- Agile course training
- [learning notes - Li Hongyi] Gan (generation of confrontation network) full series (I)
- Why does the starting service report an error when installing MySQL? (operating system Windows)
- 单片机(MCU)最强科普(万字总结,值得收藏)
- Deconvolution popular detailed analysis and nn Convtranspose2d important parameter interpretation
- The physical meaning of imaginary number J
- ArcGIS operation: converting DWG data to SHP data
- Flinkcdc failed to collect Oracle in the snapshot stage. How do you adjust this?
- ES6中的函數進階學習
猜你喜欢
ORM model -- associated fields, abstract model classes
ES类和对象、原型
Pit encountered by vs2015 under win7 (successful)
每周推荐短视频:L2级有哪些我们日常中经常会用到的功能?
Wallys/IPQ6010 (IPQ6018 FAMILY) EMBEDDED BOARD WITH ON-BOARD WIFI DUAL BAND DUAL CONCURRENT
STM32基础知识—内存映射
Google colab loads Google drive (Google drive is used in Google colab)
Qualifying 3
【ORM框架】
字节跳动 Kitex 在森马电商场景的落地实践
随机推荐
Apprentissage avancé des fonctions en es6
ISP、IAP、ICP、JTAG、SWD的编程特点
conda离线创建虚拟环境
Deadlock caused by non clustered index in SQL Server
[original] what is the core of programmer team management?
Pytest learning - dayone
The new activity of "the arrival of twelve constellations and goddesses" was launched
SolidWorks工程图中添加中心线和中心符号线的办法
单片机(MCU)最强科普(万字总结,值得收藏)
STM32基础知识—内存映射
LLVM之父Chris Lattner:为什么我们要重建AI基础设施软件
Postman interface test VII
[learning notes - Li Hongyi] Gan (generation of confrontation network) full series (I)
“十二星座女神降临”全新活动推出
In addition to the objective reasons for overtime, what else is worth thinking about?
Word自动生成目录的方法
ORM -- logical relation and & or; Sort operation, update record operation, delete record operation
Three years after graduation
2020ccpc Weihai J - Steins; Game (SG function, linear basis)
Postman interface test IV