Algorithm · Apple · Medium
A particular apple tree produces apples on each of n consecutive days. On day i, it yields apples[i] apples, and those apples become rotten after days[i] days. You can consume no more than one apple in a single day. If any apples remain unspoiled, you can continue eating them beyond the initial n days. Determine the greatest number of apples that can be eaten. Examples Example 1: Input: apples = [1,2,3,5,2], days = [3,2,1,4,2] Output: 7 This is the maximum total that can be…
Checking your access…