← back to unit
Medium
# sorting medium
The Repeated Rescue
Rescue the smallest, then the next smallest, then the next — each one joins the sorted line and stays there. ⛑️
You get a list of nums. Sort it by repeatedly finding the smallest of the UNSORTED part and swapping it into place. Print the sorted list, comma-separated.
Example:
Input: nums = [64, 25, 12, 22, 11]
Output: 11,12,22,25,64
Rescuing the smallest value from the unsorted part each round — 11 first, then 12, then 22, then 25 — builds the sorted line one position at a time.
💡 need a hint?
sort-repeated-rescue.py🔒 given lines are locked — write your code in between
loading...