We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f03b198 commit 6b98c56Copy full SHA for 6b98c56
src/com/gatsby/_1833MaximumIceCreamBars.java
@@ -0,0 +1,25 @@
1
+package com.gatsby;
2
+
3
+import java.util.Arrays;
4
5
+/**
6
+ * @ClassName: _1833MaximumIceCreamBars
7
+ * @Description: 1833. Maximum Ice Cream Bars
8
+ * @author: Gatsby
9
+ * @date: 2022/7/29 11:57
10
+ */
11
12
+public class _1833MaximumIceCreamBars {
13
+ public int maxIceCream(int[] costs, int coins) {
14
+ Arrays.sort(costs);
15
+ int count = 0;
16
+ int i = 0;
17
+ while (i < costs.length && coins - costs[i] > 0) {
18
+ coins -= costs[i++];
19
+ count++;
20
+ }
21
+ return count;
22
23
+}
24
25
0 commit comments