思路:模拟就完事
class Solution {
public:bool validateStackSequences(vector<int>& pushed, vector<int>& popped) {stack<int> c;int idx=0;for(int v:pushed){c.push(v);while(c.size()&&c.top()==popped[idx]){c.pop();idx++;}}while(c.size()){if(c.top()!=popped[idx]) return false;c.pop(); idx++;}return true;}
};