Priyanka and Toys

  • + 0 comments

    cpp

    int toys(vector<int> w) {
    sort(w.begin(),w.end());
    int counter=0;
    for(int i=0;i<w.size();i++){
        int temp=w[i];
        if(i<w.size()){
                while(temp+4>=w[i]){ 
                    i++;
                }
    
        }
        i--;
        counter++;
    }
    

    return counter; }