My issue
what is wrong in my code
My code
import java.util.*;
class Codechef
{
public static void main (String[] args)
{
Scanner read = new Scanner(System.in);
int t = read.nextInt();
int ele;
for(int i=0; i<t; i++)
{
int n = read.nextInt();
// Declare an array of size 'n'
int[] a = new int[n];
for(int j=0; j<n; j++){
a[j] = read.nextInt();
}
// sorting the array because we want to find most frequent element
Arrays.sort(a);
// Update the code below to solve the problem
ArrayList<Integer> b=new ArrayList<Integer>();
for(int j=0;j<n;j++){
b.add(Collections.frequency(a,a.get(j)));
}
m=b.size();
System.out.println(Math.abs(n-m));
}
}
}
Learning course: Solve Programming problems using Java
Problem Link: Practice problem - Make all equal using Pairs Practice Problem in Solve Programming problems using Java - CodeChef