most_frequent_char(s) that returns the character (ignoring case and spaces) that appears most often in s. If several characters tie for the highest count, return whichever one reaches that count first while scanning left to right.s = 'programming'
'r'
'r' and 'g' and 'm' all appear twice, but 'r' is the first to reach a count of 2 while scanning left to right.
s = 'aabbbcc'
'b'
'b' appears 3 times, more than any other character.
Build a frequency dictionary in one pass.
Then scan the string again, tracking the best count seen so far and only updating on a strictly higher count.