Back to course home
0% completed
Vote For New Content
Solution: Sort List
Problem Statement
Given a head of the linked list, return the list after sorting it in ascending order.
Examples
-
Example 1:
- Input:
[3, 1, 2] - Expected Output:
[1, 2, 3] - Justification: The list is sorted in ascending order, with
1coming before2, and2before3.
- Input:
-
Example 2:
- Input:
[4] - Expected Output:
[4] - Justification: A list with a single element is already sorted.
- Input:
-
Example 3:
- Input:
[9, 8, 7, 6, 5, 4, 3, 2, 1] - Expected Output:
[1, 2, 3, 4, 5, 6, 7, 8, 9]
- Input:
.....
.....
.....
Like the course? Get enrolled and start learning!