Skip to content

Instantly share code, notes, and snippets.

@shitu13
Created May 24, 2024 06:09
Show Gist options
  • Save shitu13/e1b35b58a53e8e35b4a13bb8ba701ed7 to your computer and use it in GitHub Desktop.
Save shitu13/e1b35b58a53e8e35b4a13bb8ba701ed7 to your computer and use it in GitHub Desktop.
Special Array I
class Solution {
public:
bool isArraySpecial(vector<int>& nums) {
int n = nums.size();
if (n == 1)
return true;
for (int i = 0; i < n - 1; i += 1) {
if (nums[i] % 2 == 0 && nums[i + 1] % 2 != 0)
continue;
else if (nums[i] % 2 != 0 && nums[i + 1] % 2 == 0)
continue;
else
return false;
}
return true;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment