文章目录 题目解析
题目
455. 分发饼干 – 力扣(LeetCode)
解析
分发饼干 – 分发饼干 – 力扣(LeetCode)
class Solution {public: int findContentChildren(vector<int>& g, vector<int>& s) { sort(g.begin(), g.end()); sort(s.begin(), s.end()); int numOfChildren = g.size(), numOfCookies = s.size(); int count = 0; for (int i = 0, j = 0; i < numOfChildren && j < numOfCookies; i++, j++) { vps云服务器 while (j < numOfCookies && g[i] > s[j]) { j++; } if (j < numOfCookies) { count++; } } return count; }};/*作者:LeetCode-Solution链接:https://leetcode-cn.com/problems/assign-cookies/solution/fen-fa-bing-gan-by-leetcode-solution-50se/来源:力扣(LeetCode)著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。*/ 39055543