Sum Elements at Even Indices
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[]) → intExamples
Example 1
nums = [4,1,7,3,2]return = 13The even indices are 0, 2, and 4, so the sum is 4 + 7 + 2 = 13.