Back to DSA
Sort List
hardSort a singly linked list in ascending order. Aim for O(n log n) time complexity. Return the head of the sorted list.
Examples
Example 1:
Input:
head = [6,1,4,2]Output:
[1,2,4,6] Example 2:
Input:
head = [0,9,-3,5,1]Output:
[-3,0,1,5,9]Hints
1234567