simplified format Java solution


  • 0
    R
    public ListNode deleteDuplicates(ListNode head) {
            if (head == null) { return null; }
            ListNode iter = head;
            while (iter.next != null) {
                if (iter.next.val == iter.val) {
                    iter.next = iter.next.next;
                } else {
                    iter = iter.next;
                }
            }
            return head;
        }
    

Log in to reply
 

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