Problem
Count 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.
Constraints
0 ≤ length ≤ 10,000
Examples
Input:
text = "hello"
Expected output:
expected = ["e:1", "h:1", "l:2", "o:1"]
Input:
std::string text = "hello";
Expected output:
std::vector<std::string> expected = {"e:1", "h:1", "l:2", "o:1"};
Input:
string text = "hello";
Expected output:
string[] expected = new string[] {"e:1", "h:1", "l:2", "o:1"};
Explanation
e:1, h:1, l:2, o:1 sorted by character: ["e:1", "h:1", "l:2", "o:1"].
Input:
text = "a a A"
Expected output:
expected = ["A:1", "a:2"]
Input:
std::string text = "a a A";
Expected output:
std::vector<std::string> expected = {"A:1", "a:2"};
Input:
string text = "a a A";
Expected output:
string[] expected = new string[] {"A:1", "a:2"};
Explanation
Spaces are skipped; "A" sorts before "a": ["A:1", "a:2"].
How to approach it
Try on your own first, then open one hint at a time.
Hint 1
Skip spaces, but count every other ASCII character exactly as it appears.
Hint 2
Accumulate counts in a frequency table, then output distinct characters once.
Hint 3
Sort by character code so uppercase and lowercase order naturally follows ASCII.
Expected complexity
O(n + m log m) time, O(m) extra space
References
This challenge is adapted for CodeUtility. Follow the statement and constraints above.