就是用栈做啦
include[HTML_REMOVED]
class Solution {
public:
stack[HTML_REMOVED] a;
bool isPopOrder(vector[HTML_REMOVED] pushV, vector[HTML_REMOVED] popV) {
if (popV.empty() && pushV.empty()) return true; //这里好像题目数据跟描述不一样
if (popV.size() != pushV.size()) return false;
int n = 0;
for (int i : pushV) {
a.push(i);
while (n < popV.size()) {
if (!a.empty() && a.top() == popV[n]) {
a.pop(), n++;
}
else break;
}
}
return a.empty() ? true : false;
}
};