What’s wrong with the Code? It is showing runtime error.
Run Time error with the code
hi @priyamthakuria27 do k = k%n to take care of cases where k > n
also make sure your code is running for k = 0
It says wrong answer now.
@priyamthakuria27 at least run your code for the sample input and see if output is coming out to be correct or not? Send head by reference in the insert function else linked list will not be buiilt.
Your code will still not work because you did n-- in the while loop and n becomes 0 eventually.
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.