public ListNode deleteDuplicates(ListNode head) {
        ListNode headNew = new ListNode(-1);
        headNew.next = head;
        if(head == null || head.next == null)
            return head;
        ListNode pre = headNew;
        ListNode index = pre.next;
        boolean  isDuplicates = false;
        while(index.next != null){
              if(index.val == index.next.val){
                  isDuplicates = true;
                  index.next = index.next.next;
              }else{
                  if(isDuplicates){
                      pre.next = index.next;      //delete index
                      isDuplicates = false;       //reset isDuplicates
                      index = index.next;         // move to next  but can not move pre
                  }else{
                      index = index.next;
                      pre = pre.next;
                  }

              }
        }
        if(isDuplicates){
            pre.next = null;
        }
        return headNew.next;
    }