Please Explain me how to solve this

Please explain me how to solve this question

in this question you are given a linked list of size n and k which is a factor of n. So you need to reverse the first k elements then the next k elements and so on til you reach end for example in case
6 3
1 2 3 4 5 6
answer would be
3 2 1 6 5 4.

Algorithm:

  1. Reverse the first sub-list of size k.1.1 While reversing keep track of the next node and previous node.1.2 Let the pointer to the next node be next and pointer to the previous node be prev.
  2. head->next = reverse(next, k) /* Recursively call for rest of the list and link the two sub-lists */
  3. return prev /* prev becomes the new head of the list (see the diagrams of iterative method of this post) */
    Code
    https://ide.codingblocks.com/s/257665

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.