As reported: Amazon online assessment (HackerRank, July 2025), coding question 1: an Amazon Shopping offer on
nitems with reward points that shrink after every purchase.
An offer covers n items; item i is worth pointValues[i] reward points. When you buy an item you gain its current points; then the points of every item not yet bought drop by 1, but never below 0. Each item can be bought at most once, and you may stop at any time. Return the maximum total reward points.
Example 1
pointValues = [5,2,2,3,1]
Output: 7
buy 5 (+5) → remaining [1,1,2,0]; buy the 2 (+2) → remaining [0,0,0]; nothing left to gain
Example 2
pointValues = [1,1,1]
Output: 1
Constraints: 1 ≤ n ≤ 10^5; 1 ≤ pointValues[i] ≤ 10^6. The answer can exceed 32 bits.
Code runner format: one line: pointValues as a JSON array. Implement getMaxRewardPoints(pointValues); the harness prints the result.