about | help | code help+videos | done | prefs |
Given an array of int values called nums, determine and return a boolean representing whether each adjacent pair of elements has the opposite even-oddness. Thus, if the element at index X is odd, the element at index X+1 must be even. That also means the element at index X-1 must be even. If the element at index X is even, the elements at indexes X-1 and X+1 must be odd. The above condition also applies to the pair comprised of the last and first elements of the array (the logic wraps around). We'll say that an empty array passes this test, because there are no pairs that could have the same even-oddness to serve as a reason to reject the input. HINTS: are there opportunities for early return in this problem? Are there circumstances where the alternation pattern described above is impossible? Are you dealing with negative element values appropriately? Could you update a loop control variable by different values and still get accurate results?apcsaArraysIsEvenOdd([0, 1, 2, 3]) → true apcsaArraysIsEvenOdd([1, 0, 3, 2]) → true apcsaArraysIsEvenOdd([0, 2, 1, 3]) → 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: 240
Copyright Nick Parlante 2017 - privacy