about | help | code help+videos | done | prefs |
isSpecialArray
An array is considered special if the parity of every pair of adjacent elements is different. In other words, each adjacent pair must consist of one even number and one odd number. You are given an array of integers nums. Return true if nums is a special array, otherwise return false. For example, if nums = {1}, the result is true because a single element has no adjacent pairs to violate the rule. If nums = {2, 1, 4}, the result is true because the adjacent pairs (2,1) and (1,4) both have different parity. If nums = {4, 3, 1, 6}, the result is false because the pair (3,1) contains two odd numbers. You can assume the array will have at least one element. isSpecialArray([1]) → true isSpecialArray([2, 1, 4]) → true isSpecialArray([4, 3, 1, 6]) → false ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 305
Copyright Nick Parlante 2017 - privacy