Maximum Number of Days to Survive

Asked at Amazon · Coding Questions · Difficulty: Easy

A borrower takes a new loan every day and repays each loan the next day. On day `j` the borrower receives `lender[j]`. The loan taken on day `j` must be repaid on day `j + 1` with the amount `payback[j]`. The borrower can use the money received on day `j + 1`, plus any cash left over from earlier days, to make that repayment. Any money left after the repayment carries forward.

Loading the problem…