My AC Java Result


  • 0
    D
        public ListNode deleteDuplicates(ListNode head) {
            if (head == null || head.next == null) {return head;}
            ListNode pointer = new ListNode(0);
            pointer.next = head;
            head = pointer;
            while (head.next != null && head.next.next != null) {
                if (head.next.val == head.next.next.val){
                    int val = head.next.val;
                    while (head.next != null && head.next.val == val) {
                        head.next = head.next.next;
                    }
                }
                else {
                    head = head.next;
                }
            }
            return pointer.next;
        }

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.