Problema
Ver traduçãoCount 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.
Restrições
0 ≤ length ≤ 10,000
Exemplos
Entrada:
text = "hello"
Saída esperada:
expected = ["e:1", "h:1", "l:2", "o:1"]
Entrada:
std::string text = "hello";
Saída esperada:
std::vector<std::string> expected = {"e:1", "h:1", "l:2", "o:1"};
Entrada:
string text = "hello";
Saída esperada:
string[] expected = new string[] {"e:1", "h:1", "l:2", "o:1"};
Explicação
e:1, h:1, l:2, o:1 sorted by character: ["e:1", "h:1", "l:2", "o:1"].
Entrada:
text = "a a A"
Saída esperada:
expected = ["A:1", "a:2"]
Entrada:
std::string text = "a a A";
Saída esperada:
std::vector<std::string> expected = {"A:1", "a:2"};
Entrada:
string text = "a a A";
Saída esperada:
string[] expected = new string[] {"A:1", "a:2"};
Explicação
Spaces are skipped; "A" sorts before "a": ["A:1", "a:2"].
Referências
Este desafio foi adaptado para o CodeUtility. Siga o enunciado e as restrições acima.