K reverse in linked list

https://ide.codingblocks.com/s/330726 i got reply that you should apply k=k%2 but where i should apply pls tell me.multiple times i send my code still don’t get promt reply pls resolve my doubt

Hey @shrutikatyal :smile:, i am here to help just give me some time i will reply after debugging your code and telling where’s your mistake moreover i will also you the debugged code . Just be patient.

Hey @shrutikatyal, I have spent a long time debugging your code and found to many mistakes in it.
Firstly, when you were calling Kreverse function , you weren’t updating
head=kreverse(head,k) which was a mistake .
After dry running your Kreverse function I found that your function your function was working like this


Which is not understandable at all. I would suggest you to go through this code : ide.codingblocks.com/s/331563
And dry run for this code is given below
This is for k=3
I hope, now your doubt will be resolved :grinning: , keep coding.
I know this problem was tough for you, but you did it well :grinning:

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.