Even Sum vs Odd Sum
EasyP3Coding
Let evenSum be the sum of the elements at even indices (0, 2, 4, ...) and oddSum the sum of the elements at odd indices (1, 3, 5, ...).
Return the string "Even" if evenSum > oddSum, "Odd" if oddSum > evenSum, and "Even-Odd" if they are equal.
Example 1
- Input
- nums = [5,1,4,2]
- Output
- "Even"
- Why
- even index sum 5 + 4 = 9, odd index sum 1 + 2 = 3.
Example 2
- Input
- nums = [1,9,1,9]
- Output
- "Odd"
Example 3
- Input
- nums = [3,3]
- Output
- "Even-Odd"
Constraints
- 0 <= nums.length <= 10^5
- -10^9 <= nums[i] <= 10^9
Hints
Give it a real attempt first. Run shows which examples fail.
Saved automatically
Run checks the 3 visible tests, Submit all 10. ⌘Enter runs, ⌘⇧Enter submits.