Please enter your email address or userHandle.
Given a string S and you need to check whether S contains two non overlapping substrings "XY" and "YX" in any order or not.
The first line contains an integer T denoting the number of testcases. T lines following contains string S
Print "YES" or "NO" (in new line for each testcase) corresponding answer.
1<=length of the string S<=10^5
S=XYYX; Answer= YES;
From stated input string "XY" substring(1,2) and "YX" substring(3,4) can be easily separated without overlap so output is "YES"
We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?
Login to access your submissions.
Please choose 'ReadOnlyMode' if you needn't to 'Edit' the problem e.g. viewing OJ's solution, TestCase Files (TCFs), TimeLimit etc.