Problem
A shop sells n ice cream bars; bar i costs costs[i] coins. You have coins coins and may buy the bars in any order. Return the most bars you can buy.
Example 1
- Input
- costs = [1, 3, 2, 4, 1], coins = 7
- Output
- 4
- Why
- 1 + 1 + 2 + 3
Example 2
- Input
- costs = [10, 6, 8, 7, 7, 8], coins = 5
- Output
- 0
Example 3
- Input
- costs = [1, 6, 3, 1, 2, 5], coins = 20
- Output
- 6
Constraints
costs.length == n1 <= n <= 10^51 <= costs[i] <= 10^51 <= coins <= 10^8