One obvious approach to solve this problem would be to sort the input string and then traverse through the sorted string to find the character which is occurring maximum number of times. Let us see if we can improve on this. So we will use a technique called ‘Hashing’. In this, when we traverse through the string, we would hash each character into an array of ASCII characters.
Input string = “test”
1: Construct character count array from the input string.
count['e'] = 1
count['s'] = 1
count['t'] = 2
2: Return the index of maximum value in count array (returns ‘t’).
Return maximum occurring character in an input string: https://www.geeksforgeeks.org/return-maximum-occurring-character-in-the-input-string/