#K77312. Harmonious Strings
Harmonious Strings
Harmonious Strings
You are given a string s. Your task is to determine whether the string is harmonious. A string is harmonious if and only if every distinct character in the string appears with the same frequency.
Formally, let the frequencies of the characters in the string be \(f_1, f_2, \dots, f_k\). The string is harmonious if \(f_1 = f_2 = \cdots = f_k\). Note that an empty string is considered harmonious.
For example:
- For
s = "aabb"
, both 'a' and 'b' appear twice, so the string is harmonious. - For
s = "aabc"
, 'a' appears twice while 'b' and 'c' appear once, so the string is not harmonious.
Your program should read the input from stdin
and write the result to stdout
as either True
or False
.
inputFormat
The input consists of a single line containing the string s. The string may be empty. The input is provided via stdin
.
outputFormat
Output a single line to stdout
containing True
if the string is harmonious; otherwise, output False
.
True