Delete duplicate-value nodes from a sorted linked list

  • + 1 comment
    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