Reported June 2026
Visagreedy

Maximum Even Tag Sum

Reported by candidates from Visa's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Visa OA. Under 2s to a working solution.
Founder's read

The Visa OA reported in June 2026, Maximum Even Tag Sum, looks like a free win until a negative number or an odd total wrecks your first attempt. You pick tags to get the biggest even sum, and the guarantee of at least one even tag is a hint about the edge case. It's a greedy parity problem, not dynamic programming. If you freeze on the odd-sum case during the live assessment, StealthCoder runs invisibly on your desktop as a safety net and gives you the fix in real time.

The problem

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.

Reported by candidates. Source: FastPrep

Pattern and pitfall

Take every positive value. If that sum is even, you're done. If it's odd, you must change parity by the smallest possible cost. Two options: remove the smallest positive odd number, or add the largest non-positive odd number (a negative odd, which costs its absolute value). Pick whichever leaves the bigger total. The pitfall is only handling the remove option. In Example 1 the positives sum to 23, so you drop a 1 and get 22. Zeros and negative evens never help. Another trap is forgetting that the empty set gives 0, and the guaranteed even tag means an even answer always exists. Track the min positive odd and max negative odd in one pass. O(n) time, O(1) space. If you blank on the parity swap during the live OA, StealthCoder is the hedge that surfaces it.

The honest play: practice the pattern, and have StealthCoder ready for the one you didn't see coming.

If this hits your live OA

You can drill Maximum Even Tag Sum cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play.

Get StealthCoder

Related leaked OAs

⏵ The honest play

You've seen the question. Make sure you actually pass Visa's OA.

Visa reuses patterns across OAs. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Maximum Even Tag Sum FAQ

What's the trick in Maximum Even Tag Sum?+

Sum all positive values first. If the total is even, return it. If it's odd, fix parity at minimum cost by either removing the smallest positive odd value or adding the largest negative odd value. Return the better of the two results.

Why does the guarantee of an even tag matter?+

It ensures a valid even sum always exists, so you never have to handle a no-answer case. Even if every odd option is awkward, a subset with an even sum is available. It also hints that parity adjustment is the core of the problem.

Is dynamic programming needed here?+

No. A DP over sum parity works and gives the right answer, but it's overkill. Greedy with a single pass is enough. Track the running positive sum, the smallest positive odd, and the largest negative odd. That's simpler and faster to write under pressure.

What edge cases break a naive solution?+

All-negative arrays, where the answer may be 0 or a lone even value. Odd positive sums with no positive odd to remove cleanly. Cases where adding a negative odd beats removing a positive odd. Also zeros, which are even and don't change parity.

How do I prepare for this in 48 hours?+

Write the greedy solution from scratch twice. Then test it on the Visa example, an all-negative array, an array with one odd number, and one with only evens. Focus on the two-option parity fix. That covers nearly every variant of this question.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Visa.

OA at Visa?
Invisible during screen share
Get it