Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
701 B
1
Indexable
Never
        public int getMostN(int[] a)
        {
            int maxC = 0;
            int frequentN = 0;
            for (int i = 0; i <= a.Length; i++)
            {
                int count = 0;
                {
                    for (int j = 0; j < a.Length; j++)
                    {
                        if (a[i] == a[j])
                        {
                            count++;
                        }
                    }
                    if (count > maxC)
                    {
                        maxC = count;
                        frequentN = a[i];
                    }
                }
            }
            return frequentN;
        }