Priyanka and Toys

  • + 0 comments
    int toys(vector<int> w) {
        sort(w.begin(),w.end());
        int c=0;
        size_t i = 0;
        while (i < w.size()) {
            int max = w[i] + 4;
            while (i < w.size() && w[i] <= max) {
                i++;
            }
            c++;
        }
        
        return c;
    }