Loading...
Loading...
Loading...
A linked list of order totals is in random order. Sort it in ascending order using only node operations (no sorting of a Python list) and print the result.
Example
Input
4 2 9 1 7
Output
1 2 4 7 9
Try the problem first. Open one hint at a time.
Merge sort works well: split at the middle, sort each half, merge.
Cut the first half off with slow.next = None before sorting it.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor