ListNode* deleteDuplication(ListNode* pHead)
{
if(!pHead)
return NULL;
ListNode * f = new ListNode(-1);
f->next = pHead;
ListNode * p = f;
while(p)
{
ListNode * q = p->next;
if(q)
{
ListNode * r = q->next;
if(r&&r->val == q->val)
{
while(r&&r->val==q->val)
{
r = r->next;
}
p->next = r;
continue;
}
}
p->next = q;
p = p->next;
}
return f->next;
} 
京公网安备 11010502036488号