What am I getting wrong answer for this program(MAXCOUNT)[from easy]? I have tried all possible test cases ie. for 1 occurence, for all occurence etc..Please help me find a test case where my code does not work. Thanking in advance.
import java.util.Scanner; import java.io.PrintWriter;
public class CountofMaximum { public static void main(String args[]){ Scanner sc = new Scanner(System.in); PrintWriter pw = new PrintWriter(System.out); int n = sc.nextInt(); while(n>0){ int s = sc.nextInt(); int a[] = new int[s]; int count[] = new int[s]; int i,j,max=0,occ=0; for(i=0;i<s;i++){ a[i]="sc.nextInt();" }="" for(i="0;i<s;i++){" for(j="0;j<s;j++){" if(a[i]="=a[j]){" count[i]++;="" }="" }="" }="" for(i="0;i<s;i++){" if(count[i]="">occ){ occ = count[i]; max = a[i]; } } pw.print(max+" "+occ); pw.println(); n--; } pw.flush(); sc.close(); } }