You are viewing a single comment's thread. Return to all comments →
import java.util.*; public class Solution { public static void main(String[] args) { Scanner scan=new Scanner(System.in); int n=scan.nextInt(); ArrayList<Integer> al=new ArrayList<Integer>(); for(int i=0;i<n;i++) al.add(scan.nextInt()); HashSet<Integer> hs=new HashSet<Integer>(al); ArrayList<Integer> res=new ArrayList<Integer>(); for(Integer i : hs) res.add(Collections.frequency(al,i)); System.out.println(n-Collections.max(res,null)); } }
Seems like cookies are disabled on this browser, please enable them to open this website
Equalize the Array
You are viewing a single comment's thread. Return to all comments →