Problem of the day
If the given linked list is 1 -> 2 -> 3 -> 4 -> 5 -> NULL
The first sub-list is 1 -> 3 -> 5 -> NULL.
The second sub-list is 2 -> 4 -> NULL.
The first line of input contains an integer 'T' representing the number of test cases or queries to be processed. Then the test case follows.
The only line of each test case contains the elements of the singly linked list separated by a single space and terminated by -1. Hence, -1 would never be a list element.
For each test case, print two lines representing the first and second linked lists respectively. The elements of each linked list must be separated by a single space and terminated by -1.
Print output of each test case in a separate line.
You do not need to print anything, it has already been taken care of. just implement the function and return the answer.
1 <= T <= 10^2
0 <= LEN <= 5*10^3
1 <= data <= 10^9
Where LEN is the number of nodes in the Linked List.
Time Limit: 1 sec
2
1 2 3 4 5 -1
1 2 -1
1 3 5 -1
2 4 -1
1 -1
2 -1
For the first test case, we have 1, 3, 5 in the first and 2, 4 in the second linked list.
For the second test case, we have 1 in the first and 2 in the second linked list.
2
1 2 3 -1
1 -1
1 3 -1
2 -1
1 -1
-1