2944. Minimum Number of Coins for Fruits
You are at a fruit market with different types of exotic fruits on display.
You are given a 1-indexed array
prices, whereprices[i]denotes the number of coins needed to purchase theithfruit.The fruit market has the following offer:
- If you purchase the
ithfruit atprices[i]coins, you can get the nextifruits for free.Note that even if you can take fruit
jfor free, you can still purchase it forprices[j]coins to receive a new offer.Return the minimum number of coins needed to acquire all the fruits.
1 | class Solution { |