My issue
hey could you guys guide me a bit. i wish i could see the hidden testcases by any change but heres it
My code
import java.util.*;
import java.lang.*;
import java.io.*;
class Codechef {
public static void main (String[] args) throws java.lang.Exception {
// your code goes here
Scanner sc = new Scanner(System.in);
long testCases = sc.nextLong();
while (testCases-- > 0) {
int n = sc.nextInt();
int arr[] = new int[n];
for (int i = 0; i < n; i++) {
arr[i] = sc.nextInt();
}
int freq[] = new int[n + 1];
Arrays.fill(freq, 0);
for (int i : arr) {
freq[i]++;
}
long res = Integer.MAX_VALUE;
// res = min of (n - freq[i]) * i
for (int i = 1; i < n + 1; i++) {
int val = (n - freq[i]) * i;
res = Math.min(val, res);
}
System.out.println(res);
}
sc.close();
}
}
Problem Link: Redundant Array Practice Coding Problem