Doubt in Linked List-K Append

The code is running fine but only one out of four test cases are passed.
Code https://ide.codingblocks.com/s/120789

Hello @ratulhans,

You have missed an important part of the question:
K can be greater than N.

Example:
7
1 2 2 1 8 5 6
8
Expected Output:
6 1 2 2 1 8 5
Your Output:
1 2 2 1 8 5 6
Observation:
The required output is the same as that of k=1.
Similarly,
for k=7 the output is the same as that of k=0.
for k=9 the output is the same as that of k=2.

Solution:
k = k mod n;
this would limit the value of k within the range [0,n-1]

Hope, this would help.
Give a like, if you are satisfied.

2 Likes

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.