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