Delete duplicate-value nodes from a sorted linked list

  • + 0 comments
    let node = llist
    
    while(node != null) {
        if(node.next== null) {
            return llist
        }
    
        let firstNode = node.data
        let secondNode = node.next.data   
    
        if(firstNode != secondNode) {
            node = node.next
        }         
    
        if(firstNode == secondNode) {
            node.next = node.next.next
        }
    }
    

    return llist