As reported: Salesforce MTS online assessment (HackerRank, Nov 2025): six multiple-choice questions and two coding problems; this is coding problem 1.
Given an integer array values (negative numbers allowed), choose any subset of the elements — possibly empty — so that the sum of the chosen elements is even and as large as possible. Return that sum.
Example 1
values = [2,3,6,-5,10,1,1]
Output: 22
All positives sum to 23, which is odd; dropping one 1 gives 22.
Example 2
values = [-1,-2,-3,8,7]
Output: 14
8 + 7 = 15 is odd. Dropping 7 gives 8; adding -1 instead gives 14.
Example 3
values = [-4,-3]
Output: 0
The empty subset has sum 0.
Constraints: 1 ≤ values.length ≤ 10^5; -10^9 ≤ values[i] ≤ 10^9; at least one value is even. The answer may exceed 32 bits.
Code runner format: one line: values as a JSON array. Implement maxEvenSum(values); the harness prints the sum.