diff --git a/solutions/leetcode/Problem1833.java b/solutions/leetcode/Problem1833.java new file mode 100644 index 0000000..e0a4ba2 --- /dev/null +++ b/solutions/leetcode/Problem1833.java @@ -0,0 +1,21 @@ +import java.util.*; + +public class Problem1833 { + public static void main(String[] args) { + + } + + public int maxIceCream(int[] costs, int coins) { + Arrays.sort(costs); + int index = 0; + while (coins >= 0 && index < costs.length) { + if (costs[index] <= coins) { + coins = coins - costs[index]; + } else { + break; + } + index++; + } + return index; + } +}