def most_common_char(sentence):
    if not sentence:
        return ''
max_count = 1
max_char = sentence[-1]
char_counts = defaultdict(int)
char_counts[max_char] = 1
for i in range(len(sentence) - 2, -1, -1):
    char = sentence[i]
char_counts[char] += 1
if char_counts[char] >= max_count:
    max_count = char_counts[char]
max_char = char
return max_char
Get first letter with maximum occurence of a string