Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void printLast(Node* head, int k){
- int len = 0 ;
- for (auto p= head; p!=NULL;p=p->next ){
- len ++;
- }
- auto p = head;
- for (int i=0;i<len-k;i++){
- p=p->next;
- }
- while ( p!= nullptr){
- cout << p->value <<" ";
- p=p->next ;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment