题解 | #删除有序链表中重复的元素-II#
删除有序链表中重复的元素-II
http://www.nowcoder.com/practice/71cef9f8b5564579bf7ed93fbe0b2024
struct ListNode* deleteDuplicates(struct ListNode* head ) {
// write code here
if(head==NULL)
return head;
struct ListNode* H=malloc(sizeof(struct ListNode));
H->next=head;
struct ListNode* cur=H;
while(cur->next->next!=NULL&&cur->next!=NULL)
{
if(cur->next->val==cur->next->next->val)
{
int n=cur->next->val;
while(n==cur->next->val&&cur->next!=NULL)
{
cur->next=cur->next->next;
}
}
else
{
cur=cur->next;
}
}
return H->next;
}