Given a singly linked list L0 -> L1 -> … -> Ln-1 -> Ln. Rearrange the nodes in the list so that the new formed list is : L0 -> Ln -> L1 -> Ln-1 -> L2 -> Ln-2.
You have to complete the method which takes 1 argument: the head of the linked list. You should not read any input from stdin/console. There are multiple test cases. For each test case, this method will be called individually.
Your function should return a pointer to the rearranged list so obtained.
1 <=T<= 50
1 <= size of linked lists <= 100
1 2 3 4
1 2 3 4 5
1 4 2 3
1 5 2 4 3
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.