LL- K reverse problem

I am trying to submit this on leetcode. But its giving wrong answer on submission. Please help me to figure out the mistake.

Your link has some other code. Please check.

I am sorry. Please check now.

Dry run and check your code with this case:
Your input

[1,2,3,4,5]
3

Output

[3,2,1,5,4]

Expected

[3,2,1,4,5]

You can refer this approach

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.