Untitled

 avatar
unknown
plain_text
a year ago
472 B
10
Indexable
/* 
parity==true(if the both consecutive elements are even or both odd) 
check for any consecutive elements are of same parity if it is is return false if not then return true at last
*/

class Solution {
    public boolean isArraySpecial(int[] nums) {
        for(int i=0;i<nums.length-1;i++)
        {
            if(nums[i]%2==0&&nums[i+1]%2==0)return false;
            if(nums[i]%2==1&&nums[i+1]%2==1)return false;
        }
        return true;
    }
}
Editor is loading...
Leave a Comment