Given a linked list, reverse alternate nodes and append at the end
Submissions: 4719   Accuracy:


  Difficulty: Medium   Marks: 4

Given a linked list,performs the following task

  1. Remove alternative nodes from second node
  2. Reverse the removed list.
  3. Append the removed list at the end.

Input :

You have to complete the method which takes one argument: the head of the linked list. 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.


You should not print any output to stdin/console


Input List: 1->2->3->4->5->6
After step 1 Linked list are 1>3->5 and 2->4->6
After step 2 Linked list are 1->3->5 abd 6->4->2
After step 3 Linked List is 1->3->5->6->4->2
Output List: 1->3->5->6->4->2

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

1(Number of Test cases)
10 4 9 1 3 5 9 4

10 9 3 9 4 5 1 4 

** For More Input/Output Examples Use 'Expected Output' option **

Author: Jaspreet Singh

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

Need help with your code? Please use, generate link and share the link here.

to report an issue on this page.