Given a single linked list of size N, your task is to complete the function alternatingSplitList() that splits the given linked list into two smaller list. The sublists should be made from alternating elements from the original list.
Original linked List: 5 4 3 2 1 0 Resultant Linked List 'a' 5 3 1 Resultant Linked List 'b' 4 2 0
Note: the sublist should in the order with respect to original list.
The function takes three inputs, reference pointer to the head of the original list (headRef) and two NULL reference pointer to the head of the two sublist's (aRef and bRef).
There will be multiple test cases and for each test thi function will be called seperately.
For each test case print the two sublists head1 and head2.
0 1 0 1 0 1
2 5 8 9 6
0 0 0
1 1 1
2 8 6
Note:The Input/Ouput format and Example given are used for system's internal purpose, and should be used by a user for Expected Output only. As it is a function problem, hence a user should not read any input from stdin/console. The task is to complete the function specified, and not to write the full code.
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.