Elements at Even Indices
Problem statement
Return the elements at zero-based indices 0, 2, 4 and so on, in their original order. Select by index, rather than by whether the element value is even.
Function
evenIndexElements(values: int[]) → int[]Examples
Example 1
values = [2,5,3,4,6,9,10]return = [2,3,6,10]Indices 0, 2, 4 and 6 contain 2, 3, 6 and 10.
Example 2
values = [1,2,3,4]return = [1,3]The selected values 1 and 3 are odd; their indices 0 and 2 are even.
Constraints
0 <= values.length <= 2000.-1000000 <= values[i] <= 1000000.