class Solution {
public:
bool IsPopOrder(vector<int> pushV,vector<int> popV) {
stack<int> st;
int i = 0;
for(auto e : pushV) {
st.push(e);
while(!st.empty() && st.top() == popV[i]) {
st.pop();
i++;
}
}
return st.empty();
}
};

京公网安备 11010502036488号