Javascript Solution


  • 0
    R

    I didn't see many JS solutions, so I thought I'd share

    var deleteDuplicates = function(head) {
        var current = head;
        
        while(current) {
            if(current.next !== null && current.val == current.next.val) {
                current.next = current.next.next;
            } else {
                current = current.next;
            }
        }
        
        return head;
    };
    

Log in to reply
 

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