Given an integer array nums, determine whether nums can be obtained by taking some array that is sorted in nondecreasing order and rotating it by some number of positions. Return true if such a rotation is possible, otherwise return false.
A rotation by x positions means shifting the array so that the last x elements move to the front, while preserving their relative order.
Note: A rotation by
positions is allowed.
Constraints:
nums.length
nums[i]
Given an integer array nums, determine whether nums can be obtained by taking some array that is sorted in nondecreasing order and rotating it by some number of positions. Return true if such a rotation is possible, otherwise return false.
A rotation by x positions means shifting the array so that the last x elements move to the front, while preserving their relative order.
Note: A rotation by
positions is allowed.
Constraints:
nums.length
nums[i]