Warm-ups · 24 of 24
Most frequent character
Return the character that appears most often. If several tie, return the one that appears first in the string. Return "" for an empty string.
Examples
Input s = "programming"
Output "r"
r, g and m each appear twice; r comes first.
Input s = "aabbb"
Output "b"
📘 New to this? Counting with a hash map explains the idea in a few minutes.