What is wrong with my code?

k can be greater than n as well. For example, let the linked list be - 1 2 3 4
Here n=4. Lets say k = 5.
The final linked list should be 4 1 2 3 and your code prints 1 2 3 4, which is wrong.
Try to find your mistake and tell me if you are able to do so.

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.