← back to unit
Medium
# sorting medium
Flip the Line
The drill sergeant yells ABOUT FACE! — the whole line must reverse, first becomes last. 🪖
You get a list of nums. Reverse it IN PLACE by swapping the two ends, then the next two, marching inward. Print comma-separated. (No slicing shortcuts!)
Example:
Input: nums = [1, 2, 3, 4, 5]
Output: 5,4,3,2,1
Swapping the two ends inward — 1↔5, then 2↔4 — reverses the whole line.
💡 need a hint?
sort-flip-the-line.py🔒 given lines are locked — write your code in between
loading...