LINKEDLIST K-APPEND


please check my code, sample output is same but test cases are not passing.

hello @CODER_JATIN

no bro even it is not working on sample output.
image

image

refer this , it may help

node* appendK(node *head,int k){
    node *oldHead = head;
    node *fast = head;
    node *slow = head;
    for(long i=0;i < k && fast->next!=NULL ;i++){
        fast = fast->next;
    }
    while(fast->next!=NULL && fast!=NULL){
        fast = fast->next;
        slow = slow->next;
    }
    node *newHead = slow->next;
    slow->next = NULL;
    fast->next = oldHead;
    return newHead;
}

bhaiya maanlo agar input (1 2 3 4 5 6) hua to hmari linkedlist hui (6->5->4->3->2->1) or agar hmari k ki value k=2 hui to output aani chahiye (2->1->6->5->4->3)…or yeh hi aa rhi meri output bhi… …

nahi linked list bhi tumhari 1->2->3->4->5->6 honi chaiye (tum hamesha head pe add kar rahe ho isiliye tumhara list ulta ban raha hein)

Achha , to bhaiya tail pe add kr deta hu , fir to sahi hoga ?

ha try karo. . . . .

https://ide.codingblocks.com/s/413837 , ab dekho bhaiya 2 test hue pass ab

check now->

hanji chal gya bhaiya , kya dikkat thi ??

check comments . … . … .

arey kya bat hai bhaiya , mjaa aa gya aj ye code krke …Thank you so much bhaiya

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.