Return True if nums is sorted in non-decreasing order, possibly after rotating it. A rotation moves some values from the front to the back without changing their order, so [3, 4, 5, 1, 2] is the sorted list [1, 2, 3, 4, 5] rotated. A list that is already sorted counts, and so does a list of equal values.
Example 1
Input:
check_sorted_rotated([3, 4, 5, 1, 2])
Output:
True
It is [1, 2, 3, 4, 5] rotated by 2.
Example 2
Input:
check_sorted_rotated([2, 1, 3, 4])
Output:
False
It drops twice (2 to 1, and 4 back to 2).
1 <= len(nums) <= 3 * 10**5-10**9 <= nums[i] <= 10**9No results yet
Run your code to check it against the examples, or submit to run every test.