Company: Amazon_july
Difficulty: medium
Maximum Reward Points Problem Description Amazon Shopping periodically has offers to attract more customers. It recently launched an offer for n items in its inventory, where the i th item offered pointValues[i] reward points to the customer purchasing the item. Every time an offer-bearing item is purchased, the customer gains the point values associated with that item. Then the reward points of the remaining items are reduced by 1 unless it will reduce the points below 0. Find the maximum possible reward points that can be gathered by purchasing the items optimally. Note: Each item can be purchased at most once, in other words, pointValues[i] becomes 0 after the i th item is purchased. Examples Example 1: Consider the number of items to be n = 5 , and their reward points to be pointValues = [5, 2, 2, 3, 1] . The items can be purchased as follows: Considering 0-based indexing, the items can be purchased in the following order: First, purchase item 2, points earned = pointValues[2] = 2