Algorithm · Squarepoint · Medium
First Task Given an array quantity of length n, each entry represents the starting stock level of one distinct product. A sequence of m buyers arrives. Each buyer purchases one unit of some product; if the buyer chooses product i, the revenue earned is exactly the current value of quantity[i] before that unit is removed, and then quantity[i] is lowered by 1. The total number of buyers never exceeds the total stock: $$0 \le m \le \text{sum}(quantity)$$. Your task is to decide…
Checking your access…