#C8704. Wumpsi Number Checker
Wumpsi Number Checker
Wumpsi Number Checker
You are given a number in its string representation. A number is considered a valid (\textbf{Wumpsi number}) if and only if for any digit in the number, any contiguous sequence of the same digit does not appear more than twice. In other words, if a digit (d) appears consecutively, the maximum allowed count of (d) is 2. For example, the number 122334
is valid because no digit repeats more than twice consecutively, but 1445555777
is invalid since the digit 5 appears four times in a row. An empty string is also considered valid.
Your task is to determine whether each provided number (given as a string) is a valid Wumpsi number. This problem is straightforward and can be solved by scanning through the input string and counting consecutive occurrences of the same digit.
inputFormat
The input is read from standard input (stdin). The first line contains an integer (t) ( (1 \le t \le 10^5)) representing the number of test cases. This is followed by (t) lines, each containing a non-negative integer in its string representation (possibly with leading zeros).
outputFormat
For each test case, print a single line to standard output (stdout) containing either "YES" if the input string is a valid Wumpsi number, or "NO" otherwise.## sample
3
122334
14455677
1445555777
YES
YES
NO
</p>