Skip to content

Commit 1aba007

Browse files
authored
Create 1833-maximum-ice-cream-bars.js
1 parent bb50c68 commit 1aba007

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

1833-maximum-ice-cream-bars.js

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/**
2+
* @param {number[]} costs
3+
* @param {number} coins
4+
* @return {number}
5+
*/
6+
const maxIceCream = function(costs, coins) {
7+
costs.sort((a, b) => a - b)
8+
let res = 0, idx = 0
9+
while(coins >= costs[idx]) {
10+
res++
11+
coins -= costs[idx++]
12+
}
13+
14+
return res
15+
};

0 commit comments

Comments
 (0)