Get Maximum Amount
Problem Overview
- Given n item types with quantity[i], an item's price equals the current remaining items of its type.
- With m customers each buying one item, determine the maximum revenue from selling exactly m items.
- Input: int quantity[n] and integer m; Output: long integer maximum amount; constraints up to 1e5.
- Real-world context: a greedy shopkeeper using dynamic pricing in a store setting.
- From IBM interviews; a common 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:
