Skip to content

Commit 26e18fd

Browse files
committed
Time: 0 ms (100.00%), Space: 8.4 MB (38.73%) - LeetHub
1 parent 78aa011 commit 26e18fd

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
class Solution {
22
public:
33
bool check(vector<int>& nums) {
4-
int cnt = 0;
5-
for(int i=1;i<nums.size();i++)
6-
{
4+
int count = 0;
5+
int n = nums.size();
6+
for(int i=1;i<n;i++)
77
if(nums[i] < nums[i-1])
8-
cnt++;
9-
}
10-
if(nums[nums.size()-1] > nums[0])
11-
cnt++;
8+
count+=1;
9+
10+
if(nums[n-1] > nums[0])
11+
count++;
1212

13-
return cnt<=1;
13+
return count<=1;
1414
}
1515
};

0 commit comments

Comments
 (0)