10062 - Tell me the frequencies!
This is a standard sorting problem. Since , a short algorithm will work too.
This is as straightforward as it's going to get.
1. Create an Array of size 256.
2. Iterate for each character in input string.
foreach Position in Input String
int ch = String[Position++] Array[ch]++
3. Print the Non Zero Value and its frequency from 33 to 127
- Watch out for the non-alphanumerics.
- Be careful with the output presentation. There is a blank line between the two adjacent outputs, but there is no blank lines after the last output.
67 1 66 2 65 3 49 1 50 2 51 3