My issue
I am Getting Runtime error While running my code.
My code
/* package codechef; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner sc = new Scanner(System.in);
int T = sc.nextInt();
for(int t = 0 ; t < T ; t++){
int n = sc.nextInt();
int arr[] = new int[n];
int sizeOfFreq = 2 * (int)Math.pow(10,5);
int freq[] = new int[sizeOfFreq];
for(int i = 0 ; i < n ; i++){
arr[i] = sc.nextInt();
freq[arr[i]]++;
}
int max = Integer.MIN_VALUE;
for(int i = 0 ; i < sizeOfFreq ; i++){
if(freq[i] > 1){
max = Math.max(max , freq[i]);
}
}
if(max == Integer.MIN_VALUE){
System.out.println(n-1);
}else{
System.out.println(n-max);
}
}
}
}
Learning course: Arrays, Strings & Sorting
Problem Link: CodeChef: Practical coding for everyone