Javascript Solution


  • 0
    var deleteDuplicates = function(head) {
        
        if(!head) {
            return head;
        }
       var node = head.next;
       var prev = head;
       
       while (node) {
           if (node.val !== prev.val) {
               prev.next = node;
               prev = node;
           }
           node = node.next; 
       }
       prev.next = null;
       return head 
    };

Log in to reply
 

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