My issue
someone can help in type casting what’s wrong int this
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);
int T = sc.nextInt(); // Number of test cases
while (T-- > 0) {
int n = sc.nextInt();
HashMap<Integer,Integer>map=new HashMap<Integer,Integer>();
for(int i=0;i<n;i++){
int x=sc.nextInt();
map.put(x,map.getOrDefault(x,0)+1);
}
long y=(long)Integer.MAX_VALUE;
for(Integer x:map.keySet()){
y=Math.min(y,((long)(n-map.get(x)))*((long)x));
}
System.out.println(y);
}
}
}
Problem Link: Redundant Array Practice Coding Problem