REPUB - Editorial

cakewalk
editorial
frequency

#1

PROBLEM LINK:

Practice
Contest

Author: Ranjan Kumar Singh
Tester: Ved Prakash
Editorialist: Sudipto Roy

DIFFICULTY:

CAKEWALK

PRE-REQUISITES:

Arrays

PROBLEM:

To find the alphabet with the heighest frequency.

EXPLANATION:

For the given string, first check if the string has capital alphabet or small alphabet. Increment the frequency array according to what alphabet is found.

Pseudo Code:

for i=1 to 26:
    count*=0    //counting frequency
for i=1 to l(length of string):
    if(str* is lower alphabet) count[str*-'a']++;
    else if(str* is capital alphabet) count[str*-'A']++;   //selecting heighest frequency
max_freq=0
for i=1 to 26:
    if(count*>=max_freq) max=count*,index=i

Complexity: O(N).

SOLUTIONS:

Setter's solution
Tester's solution