public static char GetMax()
        {
            string value = "GeeksForGeeks";
            char[] str = new char[value.Length];

            // to convert into char array
            for (int i = 0; i < value.Length; i++)
            {
                str[i] = value[i];
            }

            int[] count = new int[256];
            for (int i = 0; i < value.Length; i++)
            {
                count[str[i]]++;
            }

            int max = 0;
            char result = ' ';

            for (int i = 0; i < value.Length; i++)
            {
                if (max < count[str[i]])
                {
                    max = count[str[i]];
                    result = str[i];
                }
            }

            return result;            
        }
Advertisements