Given a singly linked list, the task is to rearrange it in a way that all odd position nodes are together and all even positions node are together.
First line of each testcase consists of number of testcases T. For each testcase, there will be two lines, first of which contains the length of the linked list and next will contains the elements of the linked list.
For each testcase, output the linked list after rearranging the nodes in it.
The task is to complete the function rearrangeEvenOdd() which rearranges the nodes in the linked list as required.
1 <= T <= 50
1 <= N <= 100
1 <= value <= 1000
1 2 3 4
1 2 3 4 5
1 3 2 4
1 3 5 2 4
Testcase 1: After rearranging the linked list elements in odd even fashion 1, 3 are odd and they are together. Also, 2 and 4 are even and they are together.
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.