Compare Odd- and Even-Index Sums
Problem statement
You are given an integer array values. Using zero-based indices, compute the sum at even indices and the sum at odd indices.
Return "odd" when the odd-index sum is larger, "even" when the even-index sum is larger, and "equals" when the sums are equal.
Function
compareIndexSums(values: int[]) → StringExamples
Example 1
values = [1,2,3,4]return = "odd"The even-index sum is 4 and the odd-index sum is 6.
Example 2
values = [5,1,0,4]return = "equals"Both index groups sum to 5.
Constraints
0 <= values.length <= 100000-100000 <= values[i] <= 100000