Even Odd Index Value

Element at an even index must be even, and vice-versa

Even Odd Index Value Matching

Problem Statement

Given an array of 10 elements, every element at an even index must be even, and every element at an odd index must be odd. All values are in the range 0, 100.

Your task is to generate an array that satisfies these constraints.

Constraints

  • Array size: 10
  • Index 0, 2, 4, 6, 8: must contain even values
  • Index 1, 3, 5, 7, 9: must contain odd values
  • All values: 0 ≤ value ≤ 100

Examples

Example 1:

[10, 15, 20, 25, 30, 35, 40, 45, 50, 55]
Valid
Explanation:
- Even indices (0,2,4,6,8): 10, 20, 30, 40, 50 (all even)
- Odd indices (1,3,5,7,9): 15, 25, 35, 45, 55 (all odd)

Example 2:

[2, 1, 4, 3, 6, 5, 8, 7, 10, 9]
Valid
Explanation: Alternating even-odd pattern throughout the array.

Example 3:

[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
Invalid
Explanation: Index 0 has value 1 (odd), but should be even.

Loading the interactive workspace...