Algorithm · Squarepoint · Medium
Imagine a line of n people waiting to use an ATM. Each person wants to withdraw a specific amount of cash, given by the array money, where money[i] is the amount for the i-th person (using 1‑based indexing). The ATM can dispense at most limit dollars in a single transaction. The process runs in rounds. In each round, the person currently at the front of the line withdraws up to limit dollars. If they still need more money after that, they rejoin the back of the line. If they…
Checking your access…