当前位置:网站首页>[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;
}
};
边栏推荐
- Can I open a stock trading account online? Is it safe
- Web3.0 series distributed storage IPFs
- Chris LATTNER, the father of llvm: why should we rebuild AI infrastructure software
- Analyze Android event distribution mechanism according to popular interview questions (I)
- Postman interface test I
- ORM模型--关联字段,抽象模型类
- C#记录日志方法
- Word自动生成目录的方法
- fiddler-AutoResponder
- Introduction to uboot
猜你喜欢
随机推荐
Memory ==c language 1
The new activity of "the arrival of twelve constellations and goddesses" was launched
“十二星座女神降临”全新活动推出
ORM--分组查询,聚合查询,查询集QuerySet对象特性
STM32中AHB总线_APB2总线_APB1总线这些是什么
Please ask me a question. I started a synchronization task with SQL client. From Mysql to ADB, the historical data has been synchronized normally
Win10安装VS2015
ES6中的函数进阶学习
Why does the starting service report an error when installing MySQL? (operating system Windows)
Chris Lattner, père de llvm: Pourquoi reconstruire le logiciel d'infrastructure ai
VS Code指定扩展安装位置
Horizontal split of database
Use of JSON extractor originals in JMeter
Flinkcdc failed to collect Oracle in the snapshot stage. How do you adjust this?
ORM -- database addition, deletion, modification and query operation logic
arcgis操作:dwg数据转为shp数据
Postman interface test V
Postman interface test VI
[learning notes - Li Hongyi] Gan (generation of confrontation network) full series (I)
嵌入式背景知识-芯片










