Maximum Barbell Weight
Reported by candidates from Virtu Financial's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
The data structure that carries this one is a sorted list of subset sums, and Virtu Financial's September 2026 OA leans on it. It looks like a plain knapsack, but the numbers are the trap. You get up to 42 plates and weights up to 10^9, so a capacity-indexed DP table is dead on arrival. You need a different angle, and you need it before the clock starts mattering. If you blank on the setup, StealthCoder runs invisibly during the live assessment and gives you a working solution as a safety net. Here's the trick.
The problem
An athlete is loading plates onto a barbell with maximum capacity maxCapacity. The weight of each available plate is given by weights[i]. Choose any subset of the plates, using each plate at most once. Return the maximum total plate weight that does not exceed maxCapacity. Function weightCapacity(weights: int[], maxCapacity: int) → int Examples Example 1 weights = [7,1,5,6,2] maxCapacity = 7 return = 7 There are three optimal ways to reach total weight 7: choose [7], [1,6], or [2,5]. Constraints 1 <= weights.length <= 42 1 <= maxCapacity <= 10^9 1 <= weights[i] <= 10^9
Reported by candidates. Source: FastPrep
Pattern and pitfall
This is subset sum with a huge capacity and a small n. The standard DP over capacity needs 10^9 cells, so skip it. Brute force over 2^42 subsets is also too slow. The move is meet in the middle. Split the weights into two halves of about 21 each. Generate all subset sums for each half, which is about 2 million per side. Sort the right half. For every left sum that fits under maxCapacity, binary search or two-pointer the right list for the largest value that keeps the total at or under maxCapacity. Track the best. The common pitfall is forgetting to prune sums above maxCapacity, or running a plain recursion that blows up. Generate sums iteratively to keep it fast. If the split logic slips under pressure, StealthCoder is the hedge during the live OA.
Memorize the pattern. If you can't, run StealthCoder. The proctor sees the IDE. They don't see what's behind it.
You can drill Maximum Barbell Weight 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. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass Virtu Financial's OA.
Virtu Financial reuses patterns across OAs. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Maximum Barbell Weight FAQ
What's the trick in Maximum Barbell Weight?+
Meet in the middle. Split the plates into two halves, generate every subset sum for each half, sort one list, and pair them with binary search or two pointers. It cuts 2^42 work down to roughly 2^21 times a log factor, which is fast enough.
Why doesn't normal knapsack DP work here?+
Capacity goes up to 10^9, so a DP array indexed by weight is far too large for memory and time. The small limit of 42 plates is the hint that the solution should depend on n, not on capacity.
How hard is this problem really?+
Medium-hard. The idea is well known, but you have to spot it fast and code it cleanly. Generating sums, sorting, and the pairing step each take only a few lines. Most people lose time trying DP first and backtracking out of it.
Is this subset sum pattern still asked in September 2026?+
Virtu Financial candidates reported this one in September 2026, so yes, it's live. Variants with small n and huge values keep showing up because they punish memorized capacity DP and reward noticing the constraints.
How do I prepare for this in 48 hours?+
Write meet in the middle once from scratch. Generate subset sums for a half, sort, two-pointer against the other half, and test with the example where the answer is 7. Then check edge cases: a single plate, every plate over capacity, and large values for overflow.