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

class Solution {
public:
    /**
     * 
     * @param head ListNode类 
     * @return ListNode类
     */
    ListNode* deleteDuplicates(ListNode* head) {
        // write code here   
        
        if(!head)
            return head;
        
        // head may be duplicate
        ListNode* dummy = new ListNode(1010);
        dummy->next = head;
        ListNode* cur = dummy;
        
      	// two nodes combination
        while(cur->next && cur->next->next){
            if( cur->next->val == cur->next->next->val){
              	/*  different from deleteDuplicates(I),
                	In I, we remain one from the duplicates,but here
                    all the duplicates should be deleted and there are sometimes
                    more than '2' duplicates, thus, we delete them by 'while'
                */
                int tmp = cur->next->val;
              	// 'cur->next' in while clause is non-ignorable.
              	//  program will give errors if the while clause be like 
              	// 'while(cur->next->val == tmp)'
                while(cur->next && cur->next->val == tmp)
                    cur->next = cur->next->next;
            }
            else
                cur = cur->next;
        }
        
        return dummy->next;
    }
};