My issue
time limit is exceeding.
My code
import java.util.*;
import java.lang.*;
import java.io.*;
import java.util.Arrays;
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
// your code goes here
Scanner r = new Scanner(System.in);
int t = r.nextInt();
while(t-->0 ){
int n = r.nextInt();
int[] a = new int[n];
for(int i = 0 ; i <n; i++) {
a[i] = r.nextInt();
}
int[] b = new int[n];
for (int i = 0 ; i < n; i++) {
b[i] = 0;
for (int j = 0 ; j <n; j++) {
if (a[j] == a[i]) b[i]++;
}
}
Arrays.sort(b);
int ans = n- b[n-1];
System.out.println(ans);
}
}
}
Learning course: Arrays, Strings & Sorting
Problem Link: Equal Elements Practice Problem in - CodeChef