समस्या
अनुवाद दिखाएँ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.
सीमाएँ
0 ≤ length ≤ 10,000
उदाहरण
इनपुट:
text = "hello"
अपेक्षित आउटपुट:
expected = ["e:1", "h:1", "l:2", "o:1"]
इनपुट:
std::string text = "hello";
अपेक्षित आउटपुट:
std::vector<std::string> expected = {"e:1", "h:1", "l:2", "o:1"};
इनपुट:
string text = "hello";
अपेक्षित आउटपुट:
string[] expected = new string[] {"e:1", "h:1", "l:2", "o:1"};
व्याख्या
e:1, h:1, l:2, o:1 sorted by character: ["e:1", "h:1", "l:2", "o:1"].
इनपुट:
text = "a a A"
अपेक्षित आउटपुट:
expected = ["A:1", "a:2"]
इनपुट:
std::string text = "a a A";
अपेक्षित आउटपुट:
std::vector<std::string> expected = {"A:1", "a:2"};
इनपुट:
string text = "a a A";
अपेक्षित आउटपुट:
string[] expected = new string[] {"A:1", "a:2"};
व्याख्या
Spaces are skipped; "A" sorts before "a": ["A:1", "a:2"].
संदर्भ
यह चुनौती CodeUtility के लिए अनुकूलित की गई है। ऊपर दिए गए स्टेटमेंट और सीमाओं का पालन करें।