Solution: Sort List

Let’s solve the Sort List problem using the In-Place Manipulation of a Linked List pattern.

Statement

Given the head of a linked list, return the list after sorting it in ascending order.

Constraints:

  • The number of nodes in the list is in the range [0,1000][0, 1000].

  • 103-10^3 \leq Node.value ...