solved next problem
This commit is contained in:
1 parent
7b20efe5f3
commit
026d26ad33
1 file changed
+21
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user