Given Pointer/Reference to the head of a linked list, task is to Sort the given linked list using Merge Sort.
You need to complete the function splitList() and mergeList(), which will be called by the function mergeSort().
Note: If the length of linked list is odd, then the extra node should go in the first list while splitting.
There will be multiple test cases, for each test case function mergeSort() will be called separately. The only input to the function is the pointer/reference to the head of the linked list.
For each test, in a new line, print the sorted linked list.
1 <= T <= 100
1 <= N <= 105
3 5 2 4 1
9 15 0
1 2 3 4 5
0 9 15