Given an array nums, return true if the array was originally sorted in non-decreasing order and then rotated some number of positions (including zero). Otherwise, return false. The array may contain duplicates.
Given an array nums, return true if the array was originally sorted in non-decreasing order and then rotated some number of positions (including zero). Otherwise, return false. The array may contain duplicates.
Example 1:
Input: {"nums":[3,4,5,1,2]}
Output: true
Constraints:
1≤nums.length≤100
1≤nums[i]≤100
Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result
Run code to see results.
Input
arr ={"nums":[3,4,5,1,2]}
Bend the array into a ring, so the last element points back to the first. A sorted array that was rotated has at most one place on the ring where the value drops.