样例
class Solution {
public:
bool isPopOrder(vector<int> pushV,vector<int> popV) {
int n = pushV.size(), m = popV.size();
if (n != m) return false;
stack<int> stk;
int j = 0;
for(int i = 0; i < n; i ++) {
stk.push(pushV[i]);
while(!stk.empty() && stk.top() == popV[j]){
stk.pop();
j ++;
}
}
return stk.empty();
}
};
简洁易懂!