
思路:
- class Solution {
- public:
- bool IsPopOrder(vector
pushV,vector popV) { - //辅助栈
- stack
v; - if(pushV.size()!=popV.size())
- {
- return false;
- }
-
- //定位进栈、出栈、辅助栈的下标
- int index=0;
- int outdex=0;
- while(outdex
- {
- while(v.empty()||v.top()!=popV[outdex])//直到找到 不然一直压
- {
- if(index
- {
- //压栈
- v.push(pushV[index++]);
- }
- else
- {
- return false;
- }
- }
-
- //找到之后 v出栈
- v.pop();
- outdex++;//+1
- }
- //验证完popV为正确的出栈顺序
- return true;
-
- }
- };
如有错误,多多指教
-
相关阅读:
逆向工程:揭示Google Colab未公开的秘密
算法:滑动窗口
python开发过程中注意编码规范~
WPF界面设计工具---Blend学习(一)
05.WinInet API基础
数据结构1 -- leetcode练习
LeetCode刷题复盘笔记—一文搞懂62. 不同路径 && 63. 不同路径 II(动态规划系列第三篇)
2020,XLNet: Generalized Autoregressive Pretraining for Language Understanding
02-HotSpot 虚拟机对象探秘
云计算-虚拟化
-
原文地址:https://blog.csdn.net/qq_61342044/article/details/126130305