Wrong answer in test cases

Here is my code:


it is reversing k+1 elements instead of k elements but according to me, it should reverse k elements only. kindly help

I have edited your code a bit, in line no 59, as per format, you have to take n and k as input,
and in line no 29, recursive call for next and k is to be made.