Re: [闲聊] 每日leetcode

楼主: DJYOSHITAKA (Evans)   2024-05-06 20:46:43
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;
}
作者: JIWP (JIWP)   2023-05-06 20:46:00
别卷了我不会C
作者: argorok (s.green)   2024-05-06 20:52:00
别卷了
作者: wu10200512 (廷廷)   2024-05-06 20:53:00
别卷了
作者: sustainer123 (caster)   2024-05-06 21:00:00
先开一个指向开头的linkedlist
楼主: DJYOSHITAKA (Evans)   2024-05-06 21:07:00
大师

Links booklink

Contact Us: admin [ a t ] ucptt.com