The solution has a bug. The question states
If, in the end, you are left with a sub-list with less than ‘k’ elements, reverse it too.
The solution provided does not account for that.
When the input is 1-2-3-4-5-6-7-8-9-10-11, k = 3
The output should be: 3-2-1-4-5-6-9-8-7-11-10
The output that the solution provides is :
Blockquote Nodes of reversed LinkedList are: 3 2 1 4 5 6 9 8 7 10 11