-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathLISTLIST.java
36 lines (34 loc) · 974 Bytes
/
LISTLIST.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package com.company;
import java.util.Scanner;
class Codechef_LISTLIST {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int test = sc.nextInt();
int operation=-1,g;
while(test -- > 0){
int n = sc.nextInt();
int[] arr = new int[n];
int [] count = new int[n];
g = count[0];
// int g=count[0];
for(int i=0;i<n;i++){
arr[i] = sc.nextInt();
}
for(int i=0;i<n;i++){
for(int j=0;j<n;j++)
if(arr[i]==arr[j])
count[i]++;
}
for(int i=0;i<n;i++) {
if(count[i]>g)
g = count[i];
}
if(g==0)
System.out.println("-1");
else if(g==1)
System.out.println(g);
else
System.out.println(g+1);
}
}
}