Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
If we consider costs from high to low, what is the maximum cost of a single candy that we can get for free?
How can we generalize this approach to maximize the costs of the candies we get for free?
Can “sorting” the array help us find the minimum cost?