Reverse a Linked List in groups of given size

Problem Description:

Given a linked list, write a function to reverse every k nodes (where k is an input to the function).Ifalinked list is givenas1->2->3->4->5->6->7->8->NULL and k = 3 then output will be3->2->1->6->5->4->8->7->NULL.

In this problem,method takes two argument: the head of the linked list and int k. You should not read any input from stdin/console.
The struct Node has a data part which stores the data and a next pointer which points to the next element of the linked list.
There are multiple test cases. For each test case, this method will be called individually.

Reverse the linked list in the group of given size and return the reference of starting node(head) of the reversed Linked list .

Note:If you use “Test” or “Expected Output Button” use below example format

Problem Link


Leave a Reply

Your email address will not be published. Required fields are marked *