Problem · Greedy

Find Maximum Even Sum

Learn this problem
EasyIBMFULLTIMEOA
See IBM hiring insights

Problem statement

The goal is to find the maximum possible even sum of values of tags that can be chosen.

Note:

  • It is guaranteed that there is at least one tag with an even value.
  • The tags can have positive or negative values.
  • It can be possible to choose no tags at all.
  • Function

    findMaximumEvenSum(val: int[]) → int

    Examples

    Example 1

    val = [2, 3, 6, -5, 10, 1, 1]return = 22
    Example 1 illustration
    The tags [2, 3, 6, 10, 1] sum to 22 which is even and is the maximum possible. Hence, the answer is 22.

    Constraints

    🥑🥑

    More IBM problems

    drafts saved locally
    public int findMaximumEvenSum(int[] val) {
      // write your code here
    }
    
    val[2, 3, 6, -5, 10, 1, 1]
    expected22
    checking account