#C8351. Uniform Frequency Strings
Uniform Frequency Strings
Uniform Frequency Strings
You are given a string and you need to determine if it can be rearranged such that every character appears the same number of times. A string is defined as uniform if all characters in the string occur with equal frequency.
For example, the string aabbcc
is uniform because each character appears exactly 2 times, whereas aaabbc
is not uniform since the frequencies of the characters are not equal.
You should output YES
if the string can be rearranged to be uniform, and NO
otherwise.
inputFormat
The first line contains an integer T
representing the number of test cases. Each of the following T
lines contains a non-empty string S
.
outputFormat
For each test case, print a single line containing YES
if the string can be rearranged so that every character appears the same number of times, or NO
otherwise.
3
aabbcc
aaabbc
aabccc
YES
NO
NO
</p>