Leecode<每日一题>雪糕的最大数量
Leecode<每日一题>雪糕的最大数量
题目链接:https://leetcode-cn.com/problems/maximum-ice-cream-bars/
思路:贪心,每次选着最便宜的雪糕购买,所以可以先排序。
int maxIceCream(vector<int>& costs, int coins) {
sort(costs.begin(), costs.end());
int sum = 0;
int i;
for (i = 0; i &
原创
2021-07-02 10:24:03 ·
138 阅读 ·
0 评论