My Javascript Solution


  • 0
    R
    var deleteDuplicates = function(head) {
      var history = [];
      var current = head;
      var previous = null;
      while(current){
          if(history.indexOf(current.val) >= 0){
            previous.next = current.next;
          }else{
            history.push(current.val);
            previous = current;
          }
          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.