First Adjacent Same-Parity Pair
Problem statement
Return the zero-based left index of the first adjacent pair whose two values have the same parity. Return -1 when every adjacent pair has opposite parity.
Negative odd values are treated as odd.
Function
firstSameParityPair(values: int[]) → intExamples
Example 1
values = [1,2,4,5]return = 1The first same-parity pair begins at index one.
Example 2
values = [1,2,3,4]return = -1Every adjacent pair has opposite parity.
Constraints
0 <= values.length <= 100000-1000000000 <= values[i] <= 1000000000