public ListNode deleteDuplicates2(ListNode head) {
        if (head == null || head.next == null) {
            return head;
        }
        
        ListNode dummy = new ListNode(0);
        dummy.next = head;
        
        ListNode it = dummy;
        while (it.next != null) {
            ListNode p = it;
            while (p.next.val == it.next.val) {
                p = p.next;
            }
            if (p != it.next) {
                p.next = it.next;
            }
            else
            {
                it = p;
            }
        }
        return dummy.next;
    }