Maximum Ice Cream Bars

Medium · Greedy · about 10 minutes

Asked at Amazon, Google, Meta.

costs[i] is the price of ice cream bar i, and you have coins. Return the maximum number of bars you can buy (in any order).