Maximum Amount
Problem Overview
- Find the maximum revenue selling to m customers, each buying one item of any type.
- Price rule: the sale price of an item equals the current remaining count of its type at purchase time.
- Input: quantity[n] (counts per type), m; Output: long integer maximum amount.
- Constraints: n ≤ 1e5, m ≤ 1e9, quantity[i] ≤ 1e9.
- Real-world context: greedy shopkeeper pricing/inventory management; Jpmorgan coding interview problem and interview question.
Example
Unlock to view complete problem details
and practice with sample input/output
Was this article helpful?
View Test Cases & Run Code requires membership
Input Variables
Execution Result:
