Can you tell the bug in my code?
Error in the code
Line number 91, make it as head = reverse(head,k) and then see.
Done, Nothing happened
Share your updated code with me.
oh okay, now its working fine, but can you please explain the change, like what and why did we do here?
This is fine, but I’m asking about the change you just told me to do, what was that and why did we do it?
You are updating linked list recursively so when you update for the first time you aren’t updating your head which is sent by your reverse function in form of prev ( your return statement return prev) so you will notice that only first pair of linked list isn’t updated rest linked list works fine. So you just forgot to update it in main which i mentioned here
and then you did it.
oh, okay got it thanks
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.
