Problem · Greedy
Minimum Price With Discount Coupons
Learn this problemProblem statement
A store offers n items, where price[i] is the original price of the i-th item. A customer has m discount coupons.
If x coupons are applied to the i-th item, its price is reduced to floor(price[i] / 2^x).
Return the minimum total cost to purchase all items by optimally allocating at most m coupons.
Function
findMinimumPrice(price: int[], m: int) → intExamples
Example 1
price = [2,4]m = 2return = 3Buy the first item for 2. Apply both coupons to the second item, reducing its price to floor(4 / 2^2) = 1. The minimum total cost is 2 + 1 = 3.
Constraints
1 <= price.length0 <= mprice[i] >= 0
More Agoda problems
- Minimum Absolute Difference PairsONSITE INTERVIEW · Seen Jun 2026
- Feasibility of Printing Within Given DaysONSITE INTERVIEW · Seen May 2026
- Minimum Daily Printing LimitONSITE INTERVIEW · Seen May 2026
- 3SumONSITE INTERVIEW · Seen May 2026
- Count One Groups by SizeOA · Seen Jul 2025
- Lexicographically Smallest Task QueueOA · Seen Jul 2025
- Team FormationOA · Seen Apr 2025
- Two-Core Process AssignmentOA · Seen Apr 2025