Skip to main content

3151.js

/** ------------------------------------------------------------------------------
*
* 3151. Special Array I
* Topics: Array
* https://leetcode.com/problems/special-array-i/description/
*
------------------------------------------------------------------------------ */
/**
* @param {number[]} nums
* @return {boolean}
*/
var isArraySpecial = function (nums) {
for (let i = 1; i < nums.length; i++) {
if (nums[i - 1] % 2 === nums[i] % 2) return false
}
return true
}

console.log(isArraySpecial([1, 2, 3, 4, 5]))