FastPrepMaximum Even Tag Sum
Problems/Maximum Even Tag Sum

Maximum Even Tag Sum

Visa logoVisa● EasyOA

Updated Sep 2026

QuestionFunctionExamples

Problem statement

A shop has n tags, each with a value val[i], which may be positive or negative.

A customer wants to choose a set of tags such that:

  • The sum of the chosen tag values is even.
  • The sum is as large as possible.

Additional notes:

  • There is at least one tag with an even value.
  • You may choose any number of tags, including zero.

Your task is to determine the maximum possible even sum that can be formed using any subset of the given tags.

Return this maximum even sum.

Function

maximumEvenSum(val: int[]) → int

Examples

Example 1

val = [2, 3, 6, -6, 10, 1, 1]return = 22

One valid choice is [2, 3, 6, 10, 1], whose sum is 22. Choosing both 1 tags would make the positive-tag sum odd, and adding -6 would only reduce the sum, so the maximum even sum is 22.

More Visa Online Assessment questions

  • Count Prime Values in SubtreesOA · Seen Nov 2026
  • Lock CodeOA · Seen Nov 2026
  • Minimum-Sum Tree Fill with Unit StepsOA · Seen Nov 2026
  • Longest Non-Decreasing Substring After Pair SwapsOA · Seen Oct 2026
  • Count Attack Vectors by Divisor RangeOA · Seen Oct 2026
  • Minimum Operations to Reduce a Transaction LedgerOA · Seen Oct 2026
  • Count Valid Space-Delimited WordsOA · Seen Oct 2026
  • Earliest Common Meeting StartOA · Seen Oct 2026
  • Maximum Index-Weighted Sum with Disjoint SwapsOA · Seen Oct 2026
  • Maximum Equalized Substrings After One Adjacent SwapOA · Seen Sep 2026

Similar questions at other companies

  • Catch Fish with Reusable BaitsSusquehanna International Group (SIG) · OASusquehanna International Group (SIG) interview questions
  • Server InvestmentRippling · OARippling interview questions
  • Book Reading EveningsGoogle · OAGoogle interview questions
  • Maximum Apples That Fit in a BoxVirtu Financial · OAVirtu Financial interview questions
  • Minimum Project Bid CostNVIDIA · OANVIDIA interview questions
  • Minimum AmountBelvedere Trading · OA
  • Maximum Income from Asset TradingJefferies · OA
  • Economical TripAccenture · OAAccenture interview questions
  • Best Time to Buy and Sell StockFlexTrade · OAFlexTrade interview questions
  • Minimum Pile Reduction StepsAmerican Express · OAAmerican Express interview questions
All Visa interview questionsSee Visa hiring insights
Saved
class Solution {
    public int maximumEvenSum(int[] val) {
      // write your code here
    }
}
Checking account…