MEDIUMasked at 1 company

Subsequence of Size K With the Largest Even Sum

A medium-tier problem at 36% community acceptance, tagged with Array, Greedy, Sorting. Reported in interviews at DRW and 0 others.

Founder's read

DRW asks this problem and most people tank it. The acceptance rate is 36%, which means the greedy intuition that feels right will cost you. You need a subsequence of size K from an array with the largest possible even sum. The trick isn't complicated once you see it, but in a live OA, the moment you realize your first approach is wrong, panic sets in. If this hits your assessment and you blank on the pattern, StealthCoder surfaces a working solution invisible to the proctor. The problem lives at the intersection of Greedy, Sorting, and Array manipulation. Know the move before test day.

Companies asking
1
Difficulty
MEDIUM
Acceptance
36%

Companies that ask "Subsequence of Size K With the Largest Even Sum"

If this hits your live OA

Subsequence of Size K With the Largest Even Sum is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Made by a working FAANG engineer who treats the OA the way companies treat hiring: as a game with rules you should know.

Get StealthCoder
What this means

The obvious trap: sort descending and grab the K largest elements. But their sum might be odd, and you're stuck. The real solution is greedy with a twist: sort descending, take the K largest, then check the sum's parity. If it's odd, you swap out the smallest odd number from your K elements with the largest odd number you skipped. The math is tight. You need to track both odd and even elements during the sweep, and if no valid swap exists, return -1. Most candidates code the sort and selection correctly but miss the parity correction logic or the swap condition. In a live assessment, the debugging window is small. StealthCoder is the hedge for when you see the sum's wrong parity and don't have the swap intuition locked.

Pattern tags

The honest play

You know the problem. Make sure you actually pass it.

Subsequence of Size K With the Largest Even Sum recycles across companies for a reason. It's medium-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Made by a working FAANG engineer who treats the OA the way companies treat hiring: as a game with rules you should know. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Subsequence of Size K With the Largest Even Sum interview FAQ

Is this problem still asked at DRW and similar trading firms?+

Yes. DRW appears in the input data. Trading firms love constraint-satisfaction and optimization problems. This fits that pattern. The 36% acceptance rate suggests it's a real screen filter, not a throwaway problem.

What's the trick that most people miss?+

The greedy sort works, but you must handle parity. If your K largest elements sum to odd, swap the smallest odd in your selection with the largest odd outside it. Many candidates code the sort but forget the swap or check it incorrectly.

How does Sorting fit this problem?+

Sorting is foundational. You sort descending to identify your K largest candidates, then identify odd and even elements within and outside that window. Sorting unlocks the greedy selection and the swap logic.

What happens if no valid subsequence with even sum exists?+

You return -1. This occurs when the total sum is odd and you can't perform a valid swap to flip parity. Test this edge case: all elements odd and K is odd. Common tripping point.

Is this harder than typical Array and Greedy problems?+

Not inherently. The components are standard. The difficulty is the parity check and swap condition. At 36% acceptance, most failures are logic errors in the correction step, not in the sort or selection.

Want the actual problem statement? View "Subsequence of Size K With the Largest Even Sum" on LeetCode →

Frequency and company-tag data sourced from public community-maintained interview-report repos. Problem, description, and trademark © LeetCode. StealthCoder is not affiliated with LeetCode.