Array 3151. Special Array I ¶ Time: $O(n)$ Space: $O(1)$ C++JavaPython 1 2 3 4 5 6 7 8 9class Solution { public: bool isArraySpecial(vector<int>& nums) { for (int i = 1; i < nums.size(); ++i) if (nums[i] % 2 == nums[i - 1] % 2) return false; return true; } }; 1 2 3 4 5 6 7 8class Solution { public boolean isArraySpecial(int[] nums) { for (int i = 1; i < nums.length; ++i) if (nums[i] % 2 == nums[i - 1] % 2) return false; return true; } } 1 2 3class Solution: def isArraySpecial(self, nums: list[int]) -> bool: return all(a % 2 != b % 2 for a, b in itertools.pairwise(nums))