Reported September 2024
IBMdynamic programming

Find Max Even Sum

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

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

IBM's September 2024 OA included a deceptively simple problem: find the maximum sum of elements where the count of selected elements is even. Candidates often miss the constraint entirely and build a greedy solution that doesn't guarantee an even count. The trick isn't complicated, but it's easy to blank on the even/odd logic under pressure. StealthCoder sits invisibly during your OA and feeds you the pattern the moment you freeze.

Pattern and pitfall

The core insight is that you need to track two states: the maximum sum using an even count of elements, and the maximum sum using an odd count. This is a dynamic programming pattern where you iterate through the array and update both states at each step. If you pick the greedy max without caring about parity, you'll fail test cases where the global maximum uses an odd count. The common pitfall is treating this as a standard max subarray problem. The actual pattern: at each element, decide whether to include it or not, but remember that including changes parity. StealthCoder gives you this DP skeleton in seconds if you're stuck.

If you see this problem in your OA tomorrow, the play is to recognize the pattern in 30 seconds. StealthCoder buys you that recognition.

If this hits your live OA

You can drill Find Max Even 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 by an Amazon engineer who passed his OA cold and still thinks the filter is broken.

Get StealthCoder

Related leaked OAs

⏵ The honest play

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

IBM reuses patterns across OAs. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Find Max Even Sum FAQ

Is this really just DP with two states?+

Yes. Track max_even and max_odd as you iterate. At each element, you can extend odd to even (by adding) or even to odd. You can also start fresh. The answer is max_even at the end. It's straightforward once you see the state structure.

What if all numbers are negative?+

You still need an even count. The safest answer is often 0 elements (sum = 0), which has an even count. Make sure your base case handles this. Starting max_even at 0 is usually correct.

Do I need to track indices or just sums?+

Just sums. You don't care which elements you picked, only the maximum sum with even cardinality. This keeps space O(1) and time O(n).

How do I test this before the OA?+

Write the DP solution, trace it on a small array like [1, 2, 3]. max_even should be 3 (pick 1 and 2), not 6 (all three, which is odd). If your answer is 6, you've built greedy by mistake.

Is this pattern asked elsewhere?+

Yes. It's a variant of 'maximum sum of subarray with constraint.' IBM and other companies cycle through cardinality/parity constraints regularly. The state machine approach (track even and odd) is the template.

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

OA at IBM?
Invisible during screen share
Get it