linkedlist最难的是
要回传答案的时候
对 ㄚ==
剩我一窍不通了
ListNode* removeNodes(ListNode* head) {
deque<ListNode*> q;
while(head)
{
while(!q.empty() && q.back()->val < head->val)
q.pop_back();
q.push_back(head);
head = head->next;
}
ListNode* dummy = new ListNode();
ListNode* cur = dummy;
while(!q.empty())
{
cur->next = q.front();
q.pop_front();
cur = cur->next;
}
return dummy->next;
}