排序的时候想着是不是要手写一个快排,百度了一下,发现有现成的排序方法。
import java.util.*;
class A {
int[] a = new int[10005];
public void setA(int[] aa, int n) {
for (int i = 0; i < n; i++)
a[i] = aa[i];
}
public void sortA(int n) {
Arrays.sort(a, 1, n);
}
public int ansA(int n) {
int max = 0;
int cnt = 1;
for (int i = 1; i < n; i++) {
if (a[i] == a[i - 1])
cnt++;
else {
if (cnt > max)
max = cnt;
cnt = 1;
}
}
if (cnt > max)
max = cnt;
return max;
}
}
public class Main {
public static void main(String[] args) {
Scanner inScanne = new Scanner(System.in);
A aA = new A();
int T;
T = inScanne.nextInt();
for (int k = 0; k < T; k++) {
int n = inScanne.nextInt();
int[] a = new int[10005];
for (int i = 0; i < n; i++)
a[i] = inScanne.nextInt();
aA.setA(a, n);
aA.sortA(n);
System.out.println(aA.ansA(n));
}
}
}