class Solution {
public:
int findContentChildren(vector<int>& g, vector<int>& s) {
if(s.empty() || g.empty()) return 0;
sort(g.begin(), g.end());
sort(s.begin(), s.end());
int i = 0, j = 0;
int n = g.size();
int m = s.size();
int ans = 0;
while(i < n && j < m){
if(g[i] <= s[j]){
ans++;
i ++;
j ++;
}
else j ++;
}
return ans;
}
};
分配饼干
最新推荐文章于 2023-05-14 01:14:12 发布