solved next problem
This commit is contained in:
21
solutions/leetcode/Problem1833.java
Normal file
21
solutions/leetcode/Problem1833.java
Normal file
@@ -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