FastPrepMaximize Revenue from Decreasing Inventory
Problems/Maximize Revenue from Decreasing Inventory

Maximize Revenue from Decreasing Inventory

Chubb logoChubb● MediumNEW GRADOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A report gives the pricing rule where the price drops as inventory drops, and asks for the most revenue. We chose the exact function types, what counts as possible, the numeric limits, the examples, and a 64-bit result.

A shop stocks several item types. The integer quantities[i] is the remaining inventory of type i. Selling one item from a type earns its current remaining quantity, then reduces that quantity by one.

Exactly customers customers each buy one item. Choose the item type for every sale to maximize total revenue. Return that maximum revenue.

Function

maximizeRevenue(quantities: int[], customers: int) → long

Examples

Example 1

quantities = [2,5]customers = 4return = 14

Sell from remaining quantities 5, 4, 3, and 2 for total revenue 14.

Example 2

quantities = [3,3]customers = 3return = 8

The best sale prices are 3, 3, and 2.

Constraints

  • 1 <= quantities.length <= 100000.
  • 1 <= quantities[i] <= 1000000.
  • 1 <= customers <= 1000000.
  • customers <= sum(quantities).
  • The answer fits in a signed 64-bit integer.

More Chubb Online Assessment questions

  • Count Pairs with K Divisible Values in the IntervalOA · Seen Oct 2026
  • Index of the Maximum After Left RotationsOA · Seen Oct 2026
  • Minimize the Maximum Array ElementOA · Seen Oct 2026
  • Minimum Distinct Prefix CostOA · Seen Oct 2026
  • Flat JSON Value DifferencesOA · Seen Sep 2026
  • Maximum Student-Teacher DistanceOA · Seen Sep 2026
  • Minimum Cost to Reach a Target WeightOA · Seen Sep 2026
  • Minimum Last-Element RelocationsOA · Seen Sep 2026
  • Most Visited Sprint MarkerOA · Seen Sep 2026
  • How Many Sentences?OA · Seen Sep 2026

Similar questions at other companies

  • Rearrange Songs by AuthorZomato / Eternal · OAZomato / Eternal interview questions
  • Delete and Freeze GameRubrik · OARubrik interview questions
  • Maximum Three-Server Difficulty ScoreVisa · OAVisa interview questions
  • Tennis Court SchedulingAtlassian · PHONE SCREEN · ONSITE INTERVIEWAtlassian interview questions
  • Retrieve Vectors by Cosine SimilarityHarvey · ONSITE INTERVIEWHarvey interview questions
  • Maximum Number of Events That Can Be AttendedByteDance · PHONE SCREENByteDance interview questions
  • Select K Paired Indices for Maximum ScoreAmazon · ONSITE INTERVIEW
  • Maximum Number of Events That Can Be AttendedSnowflake · PHONE SCREENSnowflake interview questions
  • Minimum Workers with Job AssignmentsLyft · ONSITE INTERVIEWLyft interview questions
  • Minimum Fuel Car AlignmentFivetran · PHONE SCREENFivetran interview questions
All Chubb interview questionsSee Chubb hiring insights
Saved
class Solution {
    public long maximizeRevenue(int[] quantities, int customers) {
        // Write your solution here.
    }

}
Checking account…