标签:public delete tno list lis turn ext || class
class Solution {
public:
ListNode *deleteDuplicates(ListNode *head) {
if (!head || !head->next) return head;
ListNode *dummy = new ListNode(-1), *pre = dummy;
dummy->next = head;
while (pre->next) {
ListNode *cur = pre->next;
while (cur->next && cur->next->val == cur->val) {
cur = cur->next;
}
if (cur != pre->next) pre->next = cur->next;
else pre = pre->next;
}
return dummy->next;
}
};
82.Remove Duplicates from Sorted List II
标签:public delete tno list lis turn ext || class
原文地址:https://www.cnblogs.com/smallredness/p/10675993.html