Merge Sort A Linked List
easy
1. You are given a partially written LinkedList class. 2. You are required to complete the body of mergeSort function. The function is static and is passed the head and tail of an unsorted list. The function is expected to return a new sorted list. The original list must not change. 3. Input and Output is managed for you. Note - Watch the question video for theory of merge sort.
Constraints
1. O(nlogn) time complexity required.
Format
Input
Input is managed for you
Output
Output is managed for you
Example
Sample Input
6
10 2 19 22 3 7
Sample Output
2 3 7 10 19 22
10 2 19 22 3 7
Question Video