题解 | #删除有序链表中重复的元素-II#
删除有序链表中重复的元素-II
http://www.nowcoder.com/practice/71cef9f8b5564579bf7ed93fbe0b2024
ListNode* deleteDuplicates(ListNode* head) { ListNode*pre = new ListNode(0); pre->next = head; ListNode*p=pre, *q=head; while(p->next!=nullptr && p->next->next!=nullptr) { if(p->next->val == p->next->next->val) { q = p->next->next; while(q!=nullptr && q->val == p->next->val) q = q->next;//找到不同就返回 p->next = q; } else p = p->next; } return pre->next; }