Linked List K-Append

I have solved the question using two methods
1.first code satisfied all test cases.
2.second approach as given in hint showing tle.

Please tell me what’s wrong in it.

@anishnair95 You are facing issues with which code? both the code are different.

@anishnair95 hey prev can remain NULL as it might never enter the loop if k>n
Make K = K%n.

1 Like

Thank you so much.Now it worked