β back to unit
Medium
# sorting medium
The Messy Middle
The shelf starts tidy and ends tidy β the chaos lives somewhere in the middle. πͺοΈ
You get a list of nums with at least one out-of-order spot. Print the position of the FIRST break and the LAST break, separated by a space (a break is a spot where a number beats its next neighbor).
Example:
Input: nums = [1, 9, 2, 8, 3, 10]
Output: 1 3
Breaks happen at position 1 (9 > 2) and position 3 (8 > 3) β those are the first and last breaks.
π‘ need a hint?
sort-messy-middle.pyπ given lines are locked β write your code in between
loading...