FastPrepElements at Even Indices
Problems/Elements at Even Indices

Elements at Even Indices

AMD logoAMD● EasyINTERNONSITE INTERVIEW
QuestionFunctionExamplesConstraints

Problem statement

Source note: The report gives [2,5,3,4,6,9,10] and asks for a list comprehension selecting even indices. Bounds, empty behavior and the callable interface are authored; approximate source match 95%.

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.

More AMD problems

  • Insert After a Linked-List NodeONSITE INTERVIEW · Seen Oct 2026
  • LRU CacheONSITE INTERVIEW · Seen Oct 2026
  • Lowest Common Ancestor of a Binary TreePHONE SCREEN · Seen Oct 2026
All AMD interview questionsSee AMD hiring insights
Saved
public int[] evenIndexElements(int[] values) {
    // Write your code here.
}
Checking account…