Efficient cpp solution


#1

int Solution::deleteandconquer(vector &A) {

unordered_map<int, int> count;

for(int i = 0; i < A.size(); i++){
    count[A[i]]++;
}

unordered_map<int,int>::iterator it = count.begin();

int ans = INT_MAX;
while(it != count.end()){
    if(ans > (A.size() - it->second))
        ans = A.size() - it->second;
    it++;
}

return ans;

}