β back to unit
Medium
# sorting medium
Bubble Until Calm
Keep doing bubble passes until a whole pass goes by with NO swaps β then the water is calm and the list is sorted. π«§β¨
You get a list of nums. Bubble-sort it yourself and print it, comma-separated.
Example:
Input: nums = [5, 1, 4, 2, 8]
Output: 1,2,4,5,8
Repeating bubble passes until one goes by with zero swaps leaves the list fully sorted.
π‘ need a hint?
sort-bubble-until-calm.pyπ given lines are locked β write your code in between
loading...