struct ListNode* deleteDuplicates(struct ListNode* head ) {
    // write code here
    struct ListNode *pre,*nxt;
    if(head==NULL||head->next==NULL)
        return head;
    pre=head;
    nxt=pre->next;
    while(nxt!=NULL)
    {
        if(pre->val==nxt->val)
        {
            pre->next=nxt->next;
            free(nxt);
            nxt=pre->next;
        }
        else
        {
          pre=pre->next;
          nxt=nxt->next; 
        }
    }
    return head;
}