#C6180. Balanced String Transformation
Balanced String Transformation
Balanced String Transformation
You are given a string consisting only of the characters a
and b
. A string is considered balanced if it contains an equal number of a
's and b
's. In this problem, you must determine whether the given string is balanced.
Note that the order of characters is not important; only the counts of a
and b
matter.
Example: the string "aabb" is balanced (2 a
's and 2 b
's), while "aaabb" is not.
inputFormat
The input begins with an integer T (T ≥ 1) representing the number of test cases. Each of the following T lines contains a non-empty string composed solely of the characters a
and b
.
outputFormat
For each test case, output a single line containing YES
if the string is balanced, or NO
otherwise.
4
aabb
abab
aaabb
bbaa
YES
YES
NO
YES
</p>