Maximum Barbell Weight
Updated
Problem statement
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) → intExamples
Example 1
weights = [7,1,5,6,2]maxCapacity = 7return = 7There are three optimal ways to reach total weight 7: choose [7], [1,6], or [2,5].
Constraints
1 <= weights.length <= 421 <= maxCapacity <= 10^91 <= weights[i] <= 10^9
More Virtu Financial Online Assessment questions
- Count Substrings With Identical CharactersOA · Seen Oct 2026
- HexSpeakOA · Seen Oct 2026
- Maximum Apples That Fit in a BoxOA · Seen Oct 2026
- Minimum Steps to a Fibonacci NumberOA · Seen Oct 2026
- Stabilize Student Test ScoresOA · Seen Oct 2026
- Maximum Sum of HeightsOA · Seen Sep 2026
- Optimal Account BalancingOA · Seen Sep 2026
- Reaching PointsOA · Seen Sep 2026
- Banking Transaction ExceptionsOA · Seen Aug 2026
- FIX Message ReconciliationOA · Seen Aug 2026
Similar questions at other companies
- Maximum Barbell WeightSalesforce · OASalesforce interview questions
- Split Array to Minimize the Largest SumInfosys · OAInfosys interview questions
- Sliding Window MedianAuxoAI · OA
- Optimize Discount Selection Under a Point BudgetPalantir · OAPalantir interview questions
- Maximum Non-Decreasing Array LengthVisa · OAVisa interview questions
- Pressure-Isolation Shutdown OrderIntuit · OAIntuit interview questions
- Minimum Cost to Make Array EqualWalmart · OAWalmart interview questions
- Maximize Array Beauty After DeletionsPoint72 · OAPoint72 interview questions
- Longest Subarray with Sum at Most KGoogle · OAGoogle interview questions
- Data ReorganizationGoldman Sachs · OAGoldman Sachs interview questions