当前位置:网站首页>【剑指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;
}
};
边栏推荐
- Wallys/IPQ6010 (IPQ6018 FAMILY) EMBEDDED BOARD WITH ON-BOARD WIFI DUAL BAND DUAL CONCURRENT
- 官媒关注!国内数字藏品平台百强榜发布,行业加速合规健康发展
- Postman interface test VI
- ORM模型--数据记录的创建操作,查询操作
- Internship log - day07
- Internship log - day04
- 企业实战|复杂业务关系下的银行业运维指标体系建设
- ORM--逻辑关系与&或;排序操作,更新记录操作,删除记录操作
- Mongodb creates an implicit database as an exercise
- ES6中的函數進階學習
猜你喜欢

Postman interface test II

ORM -- grouping query, aggregation query, query set queryset object properties

Word自动生成目录的方法

反卷积通俗详细解析与nn.ConvTranspose2d重要参数解释

Chris Lattner, père de llvm: Pourquoi reconstruire le logiciel d'infrastructure ai

Performance optimization record of the company's product "yunzhujia"

每周推荐短视频:L2级有哪些我们日常中经常会用到的功能?

ArcGIS operation: batch modify attribute table

ORM model -- associated fields, abstract model classes

VS Code指定扩展安装位置
随机推荐
Wallys/IPQ6010 (IPQ6018 FAMILY) EMBEDDED BOARD WITH ON-BOARD WIFI DUAL BAND DUAL CONCURRENT
Pytest learning - dayone
MongoDB创建一个隐式数据库用作练习
Postman interface test III
Agile course training
嵌入式背景知识-芯片
为什么安装mysql时starting service报错?(操作系统-windows)
Introduction to uboot
Check the example of where the initialization is when C initializes the program
Three years after graduation
[ORM framework]
Writing file types generated by C language
[learning notes - Li Hongyi] Gan (generation of confrontation network) full series (I)
单片机(MCU)最强科普(万字总结,值得收藏)
SQLyog数据库怎么取消自动保存更改
request对象对请求体,请求头参数的解析
CONDA creates virtual environment offline
字节跳动 Kitex 在森马电商场景的落地实践
ORM--逻辑关系与&或;排序操作,更新记录操作,删除记录操作
The request object parses the request body and request header parameters
