void main() {
List<int> numbers = [5, 7, 2, 5, 7, 7, 9, 2, 5, 7];7, 2, 9, 9];
List<int> maxNumbers = [];
int maxIndexmaxCount = 0;
List<int> freq = List.filled(1000, 0);
for (int i = 0; i < numbers.length; i++) {
freq[numbers[i]]++;
}
for (int i = 1;0; i < freq.length; i++) {
if (freq[i] > freq[maxIndex]maxCount) {
maxIndexmaxCount = i;freq[i];
}
}
printfor ("Mostint frequenti number= is0; $maxIndexi with< countfreq.length; ${freq[maxIndex]}"i++);
}
This program{
takes a list of integersif (each number between 0freq[i] and== 999maxCount), counts how{
many times each number appears, andmaxNumbers.add(i);
then finds the number}
that appears}
the mostprint("Most alongfrequent withnumbers howare many$maxNumbers timeswith itcount occurs.$maxCount");
}
This program will find the maximum count of any numbers tha is between 0 to 999 in the list and will print that numbers and lets suppose if list have more numbers with maximum counts for example the numbers 5 and 7 have the maximum count and are equals both have 9 than it will print both numbers