# java – Get the most frequent number and the least frequent duplicate in the matrix

Please, how can I optimize and improve the performance of this code? I used it to get the most frequent number and the least duplicate number in a matrix.

``````public class X {

static public string findMin (string[] numbers, int counter) {
int count = 0;
Chain elements = "";
for (String tempElement: numbers) {
int tempCount = 0;
for (int n = 0; n < numbers.length; n++) {
if (numbers[n].equals(tempElement)) {
tempCount++;
if (tempCount > counter) {
account = 0;
break;
}
if (tempCount> count) {
elements = tempElement;
// System.out.println (elements);
account = tempCount;
}
}
}
yes (account == counter) {
return elements;
}
}
yes (account <counter) {
he came back "";
}
return elements;
}

Empty main static public (String[] args) {
Rope[] numbers = "756655874075297346" .split ("");
Chain elements = "";
int count = 0;
for (String tempElement: numbers) {
int tempCount = 0;
for (int n = 0; n < numbers.length; n++) {
if (numbers[n].equals(tempElement)) {
tempCount++;
if (tempCount > tell) {
elements = tempElement;
// System.out.println (elements);
account = tempCount;
}
}
}
}
String x = "";
int c = 2;
do {
x = findMin (numbers, c ++);
} while (x == "");

System.out.println ("The frequent number is:" + elements + "Appeared" + count + "times");

System.out.println ("The minimum frequency number is:" + x + "Appeared" + (c - 1) + "times");
}
}
``````