148. Sort List
Practice Sort List for free on NudgeCode: Medium, Linked List pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.
Sort a linked list in ascending order and return the head of the sorted list. Aim for O(n log n) time.
Example
head = [4,2,1,3] -> [1,2,3,4]
Constraints
- 0 <= length of the list <= 5 * 10^4
- -10^5 <= Node.val <= 10^5