分发饼干
class Solution {
public:
int findContentChildren(vector<int>& g, vector<int>& s)
{
//需求因子和每个饼干的大小
vector<int> g_ = g;
vector<int> s_ = s;
sort(g_.begin(), g_.end());
sort(s_.begin(), s_.end());
int cookie=0;
int child=0;
//使用糖果的比较
while(child<g.size()&&cookie<s.size())
{
if(g_[child]<=s_[cookie])
{
++child;
++cookie;
}
else
{
++cookie;
}
}
return child;
}
};