#C8499. Character Frequency Counter

    ID: 52487 Type: Default 1000ms 256MiB

Character Frequency Counter

Character Frequency Counter

Given a string (S), count the frequency of each character and output the result as a list of tuples. Each tuple contains a character and its frequency. The list must be sorted in ascending order by the character.

For example, if the input is "hello", the output should be:
( [('e', 1), ('h', 1), ('l', 2), ('o', 1)] ).

inputFormat

A single line containing the string (S). The string may contain any visible characters.

outputFormat

Print the frequency list in the following exact format:
( [('c1', count1), ('c2', count2), ...] )
where each tuple represents a character and its count. The characters must be sorted in ascending order.## sample

hello
[('e', 1), ('h', 1), ('l', 2), ('o', 1)]