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