Linked-List K append

Hello sir/ma’am,
1 out of 4 test cases is not passing in my code. it shows run error. Could you please tell me why is it coming? Also, i was not able to understand how to handle k>n case, so read from discussion forum and came across k%n approach for the same. Used it, test cases also passed, but i am unable to understand why we used k%n. could you also please tell me the reason for the same.

Sharing my code:: https://ide.codingblocks.com/s/165239

Hi @priyanshi.agarwal3405
When k is greater than n then you have to only append n%k nodes. Because when k==n then we obtain the same linked list hence we only have to use k as k%n.

Here is your code and it passes all the test cases when you use k=k%n

Okay, Thank you so much sir!!