I have this Array i wrote a function MostFreq that takes an array of integers and return 2 values : the more frequent number in the array and its frequency check this code i
int count = 1; int currentIndex = 0; for (int i = 1; i < A.Length; i++) { if (A[i] == A[currentIndex]) count++; else count--; if (count == 0) { currentIndex = i; count = 1; } } int mostFreq = A[currentIndex];