Skip to main content
  1. About
  2. For Teams
added 243 characters in body
Source Link
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

void main() {
  List<int> numbers = [5, 7, 2, 5, 7, 7, 9, 2, 5, 7];
  int maxIndex = 0;

  List<int> freq = List.filled(1000, 0);
  for (int i = 0; i < numbers.length; i++) {
    freq[numbers[i]]++;
  }


  for (int i = 1; i < freq.length; i++) {
    if (freq[i] > freq[maxIndex]) {
      maxIndex = i;
    }
  }

  print("Most frequent number is $maxIndex with count ${freq[maxIndex]}");
}

This program takes a list of integers (each number between 0 and 999), counts how many times each number appears, and then finds the number that appears the most along with how many times it occurs.
void main() {
  List<int> numbers = [5, 7, 2, 5, 7, 7, 9, 2, 5, 7, 2, 9, 9];
  List<int> maxNumbers = [];
  int maxCount = 0; 


  List<int> freq = List.filled(1000, 0);
  for (int i = 0; i < numbers.length; i++) {
    freq[numbers[i]]++;
  }


  for (int i = 0; i < freq.length; i++) {
    if (freq[i] > maxCount) {
      maxCount = freq[i];
    }
  } 


  for (int i = 0; i < freq.length; i++) {
    if (freq[i] == maxCount) {
      maxNumbers.add(i);
    }
  }

  print("Most frequent numbers are $maxNumbers with count $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

Source Link

void main() {
  List<int> numbers = [5, 7, 2, 5, 7, 7, 9, 2, 5, 7];
  int maxIndex = 0;

  List<int> freq = List.filled(1000, 0);
  for (int i = 0; i < numbers.length; i++) {
    freq[numbers[i]]++;
  }


  for (int i = 1; i < freq.length; i++) {
    if (freq[i] > freq[maxIndex]) {
      maxIndex = i;
    }
  }

  print("Most frequent number is $maxIndex with count ${freq[maxIndex]}");
}

This program takes a list of integers (each number between 0 and 999), counts how many times each number appears, and then finds the number that appears the most along with how many times it occurs.
Morty Proxy This is a proxified and sanitized view of the page, visit original site.