public ListNode deleteDuplicates(ListNode head) {
        ListNode dummy = new ListNode(0);
        dummy.next = head;
        ListNode p = dummy;

        if(head == null) return head;
        while(p.next != null){
            int cur = p.next.val;
            ListNode pp = p.next;
            if(pp.next == null || pp.next.val != cur){
                p = p.next;
                continue;
            }
            while(pp.next != null && pp.next.val == cur){
                pp = pp.next;
            }
            p.next = pp.next;

        }
        return dummy.next;
    }