* struct ListNode {
 *	int val;
 *	struct ListNode *next;
 * };
 */

class Solution {
public:
    /**
     * 
     * @param head ListNode类 
     * @return ListNode类
     */
    ListNode* deleteDuplicates(ListNode* head) {
        // write code here
        if(!head||!head->next)
            return head;
        ListNode *cur,*res;
        res=new ListNode(0);
        res->next=head;
        cur=res;
        while(cur->next&&cur->next->next){
            if(cur->next->val==cur->next->next->val){
                int node=cur->next->val;
                ListNode *r;
                r=cur->next;
                while(r&&r->val==node){
                    r=r->next;
                }
                cur->next=r;
            }
            else cur=cur->next;
        }
        return res->next;
    }
};