← back to unit
Medium
# sorting medium
Almost Sorted
The tidying robot grades shelves: perfect, one-mistake, or disaster. 🤖
You get a list of nums. Count the places where a number is bigger than its next neighbor. Print sorted for zero, almost for exactly one, or messy for more.
Example:
Input: nums = [1, 2, 9, 3, 4]
Output: almost
Only one drop happens (9 > 3), so there's exactly one break — that's almost.
💡 need a hint?
sort-almost-sorted.py🔒 given lines are locked — write your code in between
loading...