Problème
Afficher la traductionCount every character in text except spaces. Report each distinct character once as "character:count", sorted by character code (so uppercase letters come before lowercase).
Implement character_frequency(text).
Input
text: The text to count (ASCII characters).
Output
Return the list of "character:count" entries.
Contraintes
0 ≤ length ≤ 10,000
Exemples
Entrée :
text = "hello"
Sortie attendue :
expected = ["e:1", "h:1", "l:2", "o:1"]
Entrée :
std::string text = "hello";
Sortie attendue :
std::vector<std::string> expected = {"e:1", "h:1", "l:2", "o:1"};
Entrée :
string text = "hello";
Sortie attendue :
string[] expected = new string[] {"e:1", "h:1", "l:2", "o:1"};
Explication
e:1, h:1, l:2, o:1 sorted by character: ["e:1", "h:1", "l:2", "o:1"].
Entrée :
text = "a a A"
Sortie attendue :
expected = ["A:1", "a:2"]
Entrée :
std::string text = "a a A";
Sortie attendue :
std::vector<std::string> expected = {"A:1", "a:2"};
Entrée :
string text = "a a A";
Sortie attendue :
string[] expected = new string[] {"A:1", "a:2"};
Explication
Spaces are skipped; "A" sorts before "a": ["A:1", "a:2"].
Références
Ce défi a été adapté pour CodeUtility. Suivez l'énoncé et les contraintes ci-dessus.