#C6297. Check Alternating Strings
Check Alternating Strings
Check Alternating Strings
You are given an integer \(T\) representing the number of test cases. For each test case, a string \(s\) is provided. Your task is to determine whether the string is alternating, meaning that no two consecutive characters in \(s\) are the same. Formally, for a string \(s\) of length \(|s|\), it must satisfy the condition:
$$\forall i\;(2 \le i \le |s|):\ s_i \neq s_{i-1}$$
Output YES if the string meets this condition and NO otherwise. The answer is case-sensitive.
inputFormat
The input is given via standard input and has the following format:
- The first line contains an integer \(T\) representing the number of test cases.
- Each of the next \(T\) lines contains a non-empty string \(s\) consisting of only printable characters.
outputFormat
For each test case, print on a new line YES if the characters of the string alternate (i.e., no two consecutive characters are the same), otherwise print NO.
## sample1
abab
YES
</p>