Skip to content

Commit 869f7ed

Browse files
authored
Create 1752. Check if Array Is Sorted and Rotated
1 parent 858ce27 commit 869f7ed

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class Solution {
2+
public:
3+
bool check(vector<int>& nums) {
4+
int n = nums.size();
5+
int count = 0;
6+
7+
for (int i = 0; i < n; i++) {
8+
if (nums[i] > nums[(i + 1) % n]) {
9+
count++;
10+
}
11+
}
12+
13+
return count <= 1;
14+
}
15+
};

0 commit comments

Comments
 (0)