Skip to content

Commit

Permalink
1833. 雪糕的最大数量
Browse files Browse the repository at this point in the history
  • Loading branch information
BGMer7 committed Jul 29, 2022
1 parent f03b198 commit 6b98c56
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/com/gatsby/_1833MaximumIceCreamBars.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.gatsby;

import java.util.Arrays;

/**
* @ClassName: _1833MaximumIceCreamBars
* @Description: 1833. Maximum Ice Cream Bars
* @author: Gatsby
* @date: 2022/7/29 11:57
*/

public class _1833MaximumIceCreamBars {
public int maxIceCream(int[] costs, int coins) {
Arrays.sort(costs);
int count = 0;
int i = 0;
while (i < costs.length && coins - costs[i] > 0) {
coins -= costs[i++];
count++;
}
return count;
}
}


0 comments on commit 6b98c56

Please sign in to comment.