The problem stats to find the most occurring alphabet and then print alphabetically. So easiest approach is to make a frequency array (count the number of letters occurring in the string)
Then as we are interested in printing the letters we are needed to take care of the indexes. So finding the maximum element from the frequency array we also need to calculate the distance from the beginning for the letter to be printed.
Finally, if there are elements having the same frequency we need to take care of that first occurrence of the letter is only counted as we need to print it alphabetically.
Hope you enjoyed !!