Problema
Mostra traduzioneCount 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.
Vincoli
0 ≤ length ≤ 10,000
Esempi
Input:
text = "hello"
Output atteso:
expected = ["e:1", "h:1", "l:2", "o:1"]
Input:
std::string text = "hello";
Output atteso:
std::vector<std::string> expected = {"e:1", "h:1", "l:2", "o:1"};
Input:
string text = "hello";
Output atteso:
string[] expected = new string[] {"e:1", "h:1", "l:2", "o:1"};
Spiegazione
e:1, h:1, l:2, o:1 sorted by character: ["e:1", "h:1", "l:2", "o:1"].
Input:
text = "a a A"
Output atteso:
expected = ["A:1", "a:2"]
Input:
std::string text = "a a A";
Output atteso:
std::vector<std::string> expected = {"A:1", "a:2"};
Input:
string text = "a a A";
Output atteso:
string[] expected = new string[] {"A:1", "a:2"};
Spiegazione
Spaces are skipped; "A" sorts before "a": ["A:1", "a:2"].
Riferimenti
Questa sfida è adattata per CodeUtility. Segui la traccia e i vincoli sopra.