Only one test case is not passing

@deepgarg46 you need to thought of a solution which will be more efficient. For algo look below :
The need of the question is to reverse every k nodes (where k is an input to the function) and k is a factor of size of List.

Example:

Inputs: 1->2->3->4->5->6->7->8->NULL and k = 3

Output: 3->2->1->6->5->4->8->7->NULL.

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) */

@pssharma1410 all the test case are work only 3rd one is not working.

@deepgarg46 Think of the case where k = size of linkedlist