Simple Java Solution using hashmap


#1

Here is a simple Solution in java

public class Solution {
public int deleteandconquer(ArrayList<Integer> A) {
    Map<Integer,Integer> map=new HashMap<>();
    
    for(int i : A){
        if(map.containsKey(i)){
            map.put(i,map.get(i)+1);
        }
        else
            map.put(i,1);
    }
    int max=0;
    for(Map.Entry<Integer,Integer> e : map.entrySet()){
        max=Math.max(max,e.getValue());
    }
    return A.size()-max;
}

}