package leetcode;

/**
 * https://leetcode.com/problems/maximum-ice-cream-bars/
 */
public class Problem1833 {
    public int maxIceCream(int[] costs, int coins) {
        // TODO
        return 0;
    }

    public static void main(String[] args) {
        Problem1833 prob = new Problem1833();
        System.out.println(prob.maxIceCream(new int[]{1,3,2,4,1}, 7)); // 4
        System.out.println(prob.maxIceCream(new int[]{10,6,8,7,7,8}, 5)); // 0
        System.out.println(prob.maxIceCream(new int[]{1,6,3,1,2,5}, 20)); // 6
    }
}

@@ -12,16 +12,42 @@
 tcode;%0A%0A
+import java.util.Arrays;%0A%0A
 /**%0A * h
@@ -195,365 +195,317 @@
     
-// TODO%0A        return 0
+int answer = 0;%0A        int currentCoins = coins
 ;%0A    
-%7D%0A%0A
     
-public static void main(String%5B%5D args) %7B%0A        Problem1833 prob = new Problem1833();%0A        System.out.println(prob.maxIceCream(new int%5B%5D%7B1,3,2,4,1%7D, 7)); // 4%0A        System.out.println(prob.maxIceCream(new int%5B%5D%7B10,6,8,7,7,8%7D, 5)); // 0%0A        System.out.println(prob.maxIceCream(new int%5B%5D%7B1,6,3,1,2,5%7D, 20)); // 6
+Arrays.sort(costs);%0A        for (int cost : costs) %7B%0A            if (currentCoins - cost %3E= 0) %7B%0A                currentCoins -= cost;%0A                answer++;%0A            %7D else %7B%0A                break;%0A            %7D%0A        %7D%0A        return answer;
 %0A   

Solve problem 1833