Sort List

Try to solve the Sort List problem.

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,5×104][0, 5 \times 10^4].
  • −105≤-10^5 \leq Node.val ≤105\leq 10^5

Examples

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.