FastPrepSum Elements at Even Indices
Problems/Sum Elements at Even Indices

Sum Elements at Even Indices

NatWest Group logoNatWest Group● EasyOA
QuestionFunctionExamples

Problem statement

You are given an integer array nums. Return the sum of the elements at even indices of the array.

Use standard zero-based indexing.

Function

sumEvenIndices(nums: int[]) → int

Examples

Example 1

nums = [4,1,7,3,2]return = 13

The even indices are 0, 2, and 4, so the sum is 4 + 7 + 2 = 13.

More NatWest Group problems

  • Remove Duplicate CharactersOA · Seen Jul 2026
See NatWest Group hiring insights
Saved
class Solution {
    public int sumEvenIndices(int[] nums) {
      // write your code here
    }
}
Checking account…