#C4456. Balanced String
Balanced String
Balanced String
In this problem, you are given a string ( s ) consisting of lowercase English letters. A string is defined as balanced if for every contiguous substring ( s[i:j] ) (where ( 0 \le i < j \leq |s| )), the number of vowels does not exceed the number of consonants. In other words, if we denote ( V(s[i:j]) ) as the number of vowels and ( C(s[i:j]) ) as the number of consonants in the substring, the string is balanced if [ V(s[i:j]) \le C(s[i:j]) \quad \text{for all } 0 \le i < j \leq |s|. ]
Your task is to determine whether the input string is balanced. If it is balanced, output "YES". Otherwise, output "NO".
Note: The input will contain several test cases.
inputFormat
The first line of input contains an integer ( T ) denoting the number of test cases. Each of the next ( T ) lines contains a single string ( s ) composed of lowercase English letters. It is guaranteed that the strings are non-empty and of manageable length.
outputFormat
For each test case, print a single line with the answer "YES" if the string is balanced, or "NO" otherwise.## sample
3
abcde
aeeiouxyz
bcdf
NO
NO
YES
</p>