//poj 1363原题
Solution{
public:
bool check_is_valid_order(std::queue order_que){
std::stack S;
int n =order_que.size();
for(int i = 0;i< n;i++){
S.push(i);
//if会导致s不为空
//if(S.top() == order_que.front()){
while(S.top() == order_que.front()){
order_que.pop();
S.pop();
}
}
if(S.empty()){
return true;
}
return false;
}
};
leetcode_栈队列堆_栈与队列模拟出入栈
最新推荐文章于 2024-03-08 22:52:04 发布