leetCode.82. 删除排序链表中的重复元素 II
题目思路:
代码
class Solution {
public:
ListNode* deleteDuplicates(ListNode* head) {
auto dummy = new ListNode(-1);
dummy->next = head;
auto p = dummy;
while(p->next){
auto q = p->next->next;
while(q && p->next->val == q->val) q = q->next;
if(p->next->next == q) p = p->next;
else p->next = q;
}
return dummy->next;
}
};