Sorted and Rotated
Return True if nums could have started as a list sorted in non-decreasing order and then been rotated by some number of positions (possibly 0). A rotation moves some items from the front to the back, keeping their order.
Repeated values are allowed.
Example 1
nums [3,4,5,1,2]
returns true
It is [1, 2, 3, 4, 5] rotated.
Example 2
nums [2,1,3,4]
returns false
No rotation of a sorted list looks like this.
Constraints
1 <= len(nums) <= 301 <= nums[i] <= 20
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.