Fewest emergency restocks to keep inventory valid

0
Remix

Your stock changes every day by task[i] (positive or negative). On days where task[i] == 0 the stock is checked and must not be negative, and at no time may the stock exceed max_products. On any day you may do an emergency restock and set the stock to whatever you like. Return the fewest restock days needed, or -1 if it cannot be done.

AmazonTechnical phone screenLast asked Jan 2026
No answer yet. Write the first one; the best answer gets endorsed.