Compute Maximum Earning Points
Learn this problemProblem statement
To attract more customers, FastPrep Shop decides to periodically launche special promotion offers.
Recently, it introduced an offer for n items in its inventory, where the i-th item grants reward[i] reward points to the customer upon purchase. Each time a customer buys an item with an offer, they receive the corresponding reward points. However, after each purchase, the reward points of all remaining items decrease by 1, unless doing so would reduce them below 0.
Please help determine the maximum possible reward points that can be accumulated by making purchases in the most strategic and optimal way.
Note
Each item can be purchased at most once, meaning that after the i-th item is bought, its reward[i] value immediately drops to 0 and cannot be earned again. In other words, once an item is purchased, it is no longer available for future transactions.
Plz complete the function in the editor by implementing the logic to maximize the total reward points collected.
The function has a parameter called int[] deals, which represents the reward points of each item in the inventory. The function should return a long integer representing the maximum reward points that can be collected.
⋅•⋅⊰∙∘☽ 🎀 Credit to eva 🎀 ☾∘∙⊱⋅•⋅
Function
getMaxRewardPoints(deals: int[]) → longExamples
Example 1
deals = [5, 2, 2, 3, 1]return = 7
Example 2
deals = [5 ,5 ,5]return = 12
Constraints
1 <= n <= 1050 < reward[i] <= 106
More Amazon problems
- Resolve Task DependenciesONSITE INTERVIEW · Seen Jul 2026
- Shortest Distance on a Circular Bus RouteOA · Seen Jul 2026
- Longest Increasing Subsequence With Bounded Adjacent DifferenceONSITE INTERVIEW · Seen Jul 2026
- Search in a Rotated Sorted ArrayONSITE INTERVIEW · Seen Jul 2026
- Sliding Window MaximumONSITE INTERVIEW · Seen Jul 2026
- Merge IntervalsOA · Seen Jul 2026
- Sort Bug Report FrequenciesOA · Seen Jul 2026
- Drone Delivery RouteOA · Seen Jul 2026