Ezvor

2431. Maximize Total Tastiness of Purchased Fruits

MediumArray Preparing judge… LeetCode
ArrayDynamic Programming

Hints

Hint 1
We have multiple options within the given budget. Trying all of them will take exponential time. How can we improve that?
Hint 2
We can use dynamic programming to speed up the algorithm.
Hint 3
We have three options for each fruit. To skip it, to buy it with a coupon, or to buy it without a coupon.