← back to unit
Medium
# puzzle gauntlet medium
Move the Zeros
The scoreboard glitched: the zeros should all sink to the END, while real scores keep their order. 🕳️
You get the nums. Print the list with all zeros moved to the back and everything else in original order, comma-separated.
Example:
Input: nums = [0, 5, 0, 3, 8]
Output: 5,3,8,0,0
Collecting the non-zero values in order (5, 3, 8) and appending the 2 zeros that were skipped gives 5,3,8,0,0.
💡 need a hint?
pg-move-the-zeros.py🔒 given lines are locked — write your code in between
loading...