Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 40121

Help me with MAXCOUNT test cases where my program does not work

$
0
0

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&lt;s;i++){" for(j="0;j&lt;s;j++){" if(a[i]="=a[j]){" count[i]++;="" }="" }="" }="" for(i="0;i&lt;s;i++){" if(count[i]="">occ){ occ = count[i]; max = a[i]; } } pw.print(max+" "+occ); pw.println(); n--; } pw.flush(); sc.close(); } }


Viewing all articles
Browse latest Browse all 40121

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>