Check if Array is Sorted and Rotated
unknown
c_cpp
a year ago
357 B
3
Indexable
class Solution { public: bool check(vector<int>& nums) { int count = 0; int n = nums.size(); for(int i = 1; i< n; i++){ if(nums[i - 1]> nums[i]){ count++; } } if(nums[n - 1]> nums[0]){ count++; } return count <= 1 ; } };
Editor is loading...
Leave a Comment