class Solution {
public:
int findContentChildren(vector<int>& g, vector<int>& s) {
sort(g.begin(),g.end());
sort(s.begin(),s.end());
int i=0,j=0;
while(i<g.size()&&j<s.size()){
if(g[i]<=s[j]){
i++;
}
j++;
}
return i;
}
};
2020-10-06 greedy algorithm
最新推荐文章于 2023-09-29 11:19:12 发布