https://ide.codingblocks.com/s/47319
only one test case passed
Linl list append
Hey Anshu, it is mentioned in the problem that K can be greater than N, you are not handling that case.
Hey Anshu, the case when k>=n is still not handled in your code. you can use an if check for that. You can refer this code snippet, here i have written the if check that you should write before calling the knode function
if(k>=n){
k=k%n;
}
node*temp=knode(head,k,n);
Also, you can check your code for this case,
input:
5
1 3 5 7 9
6
your code’s output:
Output
in reverse value of k6
in reverse value of k6
7 5 3 1
but the correct output is:
9 1 3 5 7