Compute Maximum Earning Points
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 🎀 ☾∘∙⊱⋅•⋅
1Example 1

2Example 2

Constraints
Limits and guarantees your solution can rely on.
1 <= n <= 10^50 <= deals[i] <= 10^6