My 1ms Solution (java)


  • 0
    R

    public ListNode deleteDuplicates(ListNode head) {
    ListNode temp = head;
    while(temp != null && temp.next != null){
    if(temp.val == temp.next.val){
    temp.next = temp.next.next;
    }
    else if(temp.val != temp.next.val)
    temp = temp.next;
    }
    return head;
    }


Log in to reply
 

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