typedef struct ListNode Node;
struct ListNode* deleteDuplication(struct ListNode* pHead ) {
Node* Pre = NULL;
Node* node = pHead;
Node* tmp;
Node* del;
int tmp_val;
int flag;
if (!pHead)
return NULL;
while (node != NULL)
{
tmp = node->next;
flag = 0;
if (tmp!= NULL && tmp->val == node->val)
flag = 1;
if (!flag)
{
Pre = node;
node = node->next;
}
else
{
tmp_val = node->val;
del = node;
while (del!=NULL&&del->val== tmp_val)
{
tmp = del->next;
free(del);
del = NULL;
del = tmp;
}
if (Pre == NULL)
pHead = tmp;
else
Pre->next = tmp;
node = tmp;
}
}
return pHead;
}