Leetcode in Java && Oracle
419 subscribers
8 photos
397 files
400 links
Second channel: @codeforces_java

Let's Develop Together!
Download Telegram
image_2021-11-15_01-43-45.png
30.7 KB
#medium

#N1833. Maximum Ice Cream Bars
problem link

#solution
class Solution {
public int maxIceCream(int[] costs, int coins) {
int count=0;
Arrays.sort(costs);

for(int i=0; i<costs.length&&coins>0; i++){
if(costs[i]<=coins){
coins-=costs[i];
count++;
}
}
return count;
}
}