Shreyansh has been given a string for evaluation by his teacher. He needs to find out whether the given string is non-repetitive or not.
A non-repetitive string is defined as a string which does not contain any different character between 2 same characters (Refer example for explanation).
The first line of input contains a single integer T denoting the number of test cases. Each test case contains a string S which consists only of upper-case English alphabets.
For each test case, print 1 if the string is non-repetitive, else print 0 in a new line.
1 <= T <= 200
2 <= Length of String S <= 10^4
Case 1 :
Here no different character is placed between 2 same characters.
Case 2 :
Here 2 B's are placed between 2 A's, so this is not a non-repetitive string.
Case 3 :
Here 1 B, 1 C, 1 D are placed between 2 A's, so this is not a non-repetitive string.
If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.