My issue
I was stuck at a testcase in contest.After contest I solve it in practice.
I see the testcase where i stuck then i correct it after running again it again wrong answer so i run into my vscode with the same testcase and it showing correct answer and showing wrong answer in codechef.
My code
import java.util.*;
import java.lang.*;
import java.io.*;
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner sc=new Scanner(System.in);
int N=sc.nextInt();
for(int x=0;x<N;x++){
int n=sc.nextInt();
HashMap<Integer,Integer> H=new HashMap<>();
for(int i=0;i<n;i++){
int v=sc.nextInt();
H.put(v,H.getOrDefault(v,0)+1);
}
int ans=H.size();
for(int i=n;i>H.size();i--){
if((i%H.size())==0){
ans=i;
break;
}
}
System.out.println(ans);
}
}
}
Problem Link: Largest K Practice Coding Problem