This keeps rest part of list intact .
if ( count == n ) { ListNode * d = c -> next ; c -> next = link ; end -> next = d ; ListNode * head = A ; while ( head != NULL ) { cout << head -> data << " ▁ " ; head = head -> next ; } return ; } c = c -> next ; } }