1752. Check if Array Is Sorted and Rotated
Problem Statement
Input: nums = [3,4,5,1,2]
Output: true
Explanation: [1,2,3,4,5] is the original sorted array.
You can rotate the array by x = 3 positions to begin on the the element of value 3: [3,4,5,1,2].Input: nums = [2,1,3,4]
Output: false
Explanation: There is no sorted array once rotated that can make nums.Input: nums = [1,2,3]
Output: true
Explanation: [1,2,3] is the original sorted array.
You can rotate the array by x = 0 positions (i.e. no rotation) to make nums.Intuition
Links
Video Links
Approach 1:
Approach 2:
Approach 3:
Approach 4:
Similar Problems
Last updated