# sorting medium

Count the Swaps

How much WORK did the bubbles do? Every swap costs one bubble-coin. πŸͺ™

You get a list of nums. Bubble-sort it, but print only the TOTAL number of swaps it took.

Example:

Input: nums = [3, 1, 2] Output: 2

Bubble-sorting swaps 3 and 1 (3,1,2 β†’ 1,3,2), then swaps 3 and 2 (1,3,2 β†’ 1,2,3) β€” 2 swaps in total.

πŸ’‘ need a hint?

sort-count-the-swaps.pyπŸ”’ given lines are locked β€” write your code in between
loading...