id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

amjadm@miamioh.edu project5 > isSpecialArray
prev  |  next  |  chance

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)

public boolean isSpecialArray(int[] nums) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 305

Copyright Nick Parlante 2017 - privacy