Algorithm · Amazon · Medium
Requirements You are given an array inventory[] with n entries representing the starting stock for each VM type, along with an integer m indicating how many rentals occur. For every rental, choose a VM type whose stock is currently highest; any choice is acceptable when several types share that highest value. Earn current_max + current_nonzero_min, then reduce the selected type's stock by 1. Compute the combined revenue earned after all m rentals. Examples The total is 26…
Checking your access…