Special Array I

An array is special if every pair of adjacent elements has two numbers with different parity, meaning one is odd and the other is even. Given an array of integers nums, return true if nums is special, otherwise return false.

30:00

Special Array I
easy
Free written solution
Topics
Companies

An array is special if every pair of adjacent elements has two numbers with different parity, meaning one is odd and the other is even. Given an array of integers nums, return true if nums is special, otherwise return false.

Example 1:
Input: {"nums":[1]}
Output: true
Constraints:
  • 1≤nums.length≤1001 \leq \text{nums.length} \leq 100

  • 1≤nums[i]≤1001 \leq \text{nums}[i] \leq 100

Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result

Run code to see results.

Input
arr ={"nums":[1]}

1 numbers. Special means every neighbouring pair mixes one odd and one even number.

odd

even

links checked: 0 / 0

nums as a chain

1

0

Variables
VariableValue
n1
DepthFunction Call
Stack empty
0/3