. Assign Cookies

 class Solution {

public:

   int findContentChildren(vector<int>& g, vector<int>& s) {

        sort(g.begin(), g.end());

        sort(s.begin(), s.end());       

        int count = 0;       

        for(int j = 0; count < g.size() && j < s.size(); ++j){

            if(g[count] <= s[j]) count++;

        }    

        return count;

    }

};

Comments

Popular posts from this blog

class with array in c++ (memory allocatin & using array in classes)

constructor with default arguments

constructor overloading in c++ programming