leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

1833.cpp (299B)


      1 class Solution {
      2   public:
      3     int maxIceCream(vector<int> &costs, int coins) {
      4         sort(costs.begin(), costs.end());
      5         int index = 0, count = 0;
      6         while (index < costs.size() && coins - costs[index] >= 0)
      7             coins -= costs[index++], count++;
      8         return count;
      9     }
     10 };