← Questions

Fewest emergency restocks to keep inventory valid

0
AmazonCodingLast asked Jan 2026

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.

Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding