Skip to content · ⁨Passer au contenu⁩

Most frequent character · ⁨Caractère le plus fréquent⁩

English

Most frequent character

Return the character that appears most often in a non-empty String. If two characters tie, return the one that appears earliest. A simple approach: for each character, count how many times it occurs, and keep the best so far — using a strict > so a tie keeps the earlier character.

Français

Caractère le plus fréquent

Retournez le caractère qui apparaît le plus souvent dans un String non vide. Si deux caractères font match, retournez celui qui apparaît en premier. Une approche simple : pour chaque caractère, comptez combien de fois il apparaît, et gardez le meilleur jusqu'ici — en utilisant un strict > pour qu'une égalité conserve le caractère précédent.

Log in or create account · ⁨Se connecter ou créer un compte⁩

IGCSE, A-Level & AP