Linked list k append

why my code is failing 2 test case
code: https://ide.codingblocks.com/s/139149

Hello @Chitra_Singla,

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.

Ok…I though that k>n will not affect the output
Thanks

@Chitra_Singla Anytime:blush:

Please, mark this as resolved.
BTW, I won’t mind a like.:rofl:

2 Likes