Skip to content

Latest commit

 

History

History
27 lines (22 loc) · 540 Bytes

File metadata and controls

27 lines (22 loc) · 540 Bytes
int findContentChildren(vector<int>& g, vector<int>& s) {
        
        sort(g.begin(),g.end());
        sort(s.begin(),s.end());

        int ans=0;
        int i=0,j=0;

        while(i<g.size() && j<s.size())
        {
            if(s[j]>=g[i])
            {
                ans++;
                i++;
                j++;
            }

            else
            {
                j++;
            }
        }
        return ans;
    }