leetcode

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

0455.cpp (325B)


      1 class Solution {
      2   public:
      3     int findContentChildren(vector<int> &g, vector<int> &s) const {
      4         sort(rbegin(g), rend(g));
      5         sort(rbegin(s), rend(s));
      6         int i = 0, j = 0;
      7         while (i < g.size() && j < s.size()) {
      8             if (g[i] <= s[j]) j++;
      9             i++;
     10         }
     11         return j;
     12     }
     13 };