pretty JAVA solution with while loop


  • 0
    L
    public ListNode deleteDuplicates(ListNode head) {
            if(head==null||head.next==null) return head;
            ListNode cur=head;
            while(cur!=null){
                while(cur.next!=null && cur.val==cur.next.val){
                    cur.next = cur.next.next;
                }
                cur = cur.next;
            }
            return head;
        }
    

Log in to reply
 

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