Is this allowed in interview, use dynamic language attribute?


  • 0
    B
    var deleteDuplicates = function(head) {
        var dummy = new ListNode(0);
        dummy.next = head;
        
        var node = head;
        while(node) {
            if (node.next && node.val === node.next.val) {
                node.del = true;
                node.next.del = true;
            }
            
            node = node.next;
         }
         
        node = dummy;
        while(node) {
            if (node.next && node.next.del) {
                node.next = node.next.next;
                continue;
            } 
            
            node = node.next;
        }
        
        return dummy.next;
    };

Log in to reply
 

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