Maximum Ice Cream Bars LeetCode solution in Java
1class Solution {2public int maxIceCream(int[] costs, int coins) {34// Greedy Approach5// a. sort cost in increasing order67Arrays.sort(costs);89int count = 0;10for (int cost : costs) {1112// b. check remainig coin is greater or equal than cuurent ice - cream cost13if (coins - cost >= 0) {14coins -= cost;15count++;16}17}1819return count;20}21}