Skip to content

Commit 4cd03d4

Browse files
authored
Add files via upload
1 parent 6406b96 commit 4cd03d4

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-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 length=nums.size();
5+
int counter =0;
6+
7+
for (int i =0; i<length; i++)
8+
{
9+
if (nums[i]>nums[(i+1)%length]) counter++; //Compare with the next element wrapping around
10+
}
11+
return counter <=1; // Return true if thre is at most one drop otherwise return false
12+
}
13+
14+
15+
};

3151. Special Array I.cpp

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

0 commit comments

Comments
 (0)