当前位置:网站首页>【剑指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;
}
};
边栏推荐
- The story of Plato and his three disciples: how to find happiness? How to find the ideal partner?
- MongoDB创建一个隐式数据库用作练习
- The Himalaya web version will pop up after each pause. It is recommended to download the client solution
- Luogu p2482 [sdoi2010] zhuguosha
- Can I open a stock trading account online? Is it safe
- Introduction to uboot
- ArcGIS operation: batch modify attribute table
- Integer inversion
- Hcip first day notes sorting
- Applet sliding, clicking and switching simple UI
猜你喜欢
Some thoughts on the testing work in the process of R & D
【ORM框架】
ORM--查询类型,关联查询
Official media attention! The list of top 100 domestic digital collection platforms was released, and the industry accelerated the healthy development of compliance
Performance optimization record of the company's product "yunzhujia"
[learning notes - Li Hongyi] Gan (generation of confrontation network) full series (I)
高数_第1章空间解析几何与向量代数_向量的数量积
Basic chapter: take you through notes
官媒关注!国内数字藏品平台百强榜发布,行业加速合规健康发展
“十二星座女神降临”全新活动推出
随机推荐
UnityWebRequest基础使用之下载文本、图片、AB包
The combination of over clause and aggregate function in SQL Server
Why are social portals rarely provided in real estate o2o applications?
Video based full link Intelligent Cloud? This article explains in detail what Alibaba cloud video cloud "intelligent media production" is
Some test points about coupon test
Become a "founder" and make reading a habit
Internship log - day04
CONDA creates virtual environment offline
CDZSC_ 2022 winter vacation personal training match level 21 (2)
Weekly recommended short videos: what are the functions of L2 that we often use in daily life?
Check the example of where the initialization is when C initializes the program
ORM model -- creation and query of data records
Word自动生成目录的方法
Finally, there is no need to change a line of code! Shardingsphere native driver comes out
Sword finger offer II 107 Distance in matrix
14th test
中国首款电音音频类“山野电音”数藏发售来了!
Analyze Android event distribution mechanism according to popular interview questions (I)
The Himalaya web version will pop up after each pause. It is recommended to download the client solution
大整数类实现阶乘