Linked List K append

i tried it using the hint video approach , but getting only 2 test cases correct and rest TLE kindly tell the mistake.

hi @ujj1804_1156aee80205d0bf
to avoid TLE, u can add this statement

k = k%n;

refer this code -->

Sir the logic of my code is also the same but the syntax is a bit different from yours , it would be very helpful if you could tell me the mistake in my code , i got 3 test cases right out of 6 .

@ujj1804_1156aee80205d0bf

k = k%n;

u just have to add this line to ur code… ur code will pass all test cases…
corrected code -->

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.

Thank you sir for the help , we did k=k%n so that if k is larger than n we could append n-k elements only ?

Yes @ujj1804_1156aee80205d0bf

1 Like