Only failing for the last test case .. what could it be? and why?

here language used is java

@Muskan-Gupta-598128740703036
Try this testcase -
Input :
1
abcdefgh
cdabghef

Expected Output :
YES

Your Output :
NO

sir iska ans yes kyu aayga

jo input aapne bheja hai

@Muskan-Gupta-598128740703036
s1 = “abcdefgh”
Break s1 into two parts , say
s11 = “abcd” and s12 = “efgh”
Similarly, break s2 = " cdabghef" into two parts as well.
s21 = “cdab” and s22 = “ghef”

Two strings a and b of equal length are called equivalent in one of the two cases:

  1. They are equal.
  2. If we split string a into two halves of the same size a1 and a2, and string b into two halves of the same size b1 and b2, then one of the following is correct:
    1. a1 is equivalent to b1, and a2 is equivalent to b2
    2. a1 is equivalent to b2, and a2 is equivalent to b1

    s1 and s2 are equivalant if either s1 and s2 are equal , which are they are clearly not. Else s1 and s2 are also equivalant if

    • s11 is equivalant to s21 and s12 is equivalant to s22 , or
    • s11 is equivalant to s22 and s12 is equivalant to s21

    The second possibility will surely come out to be false. So lets consider the first possibility only.
    We need to check if s11=“abcd” is equivalant to s21=“cdab”. Repeat the same checks as above.
    Since s11 can be divided as s111=“ab” and s112=“cd” and s21 can be divided as s211=“cd” and s212=“ab” and clearly
    s111 = s212 and s112 = s211 , hence
    s11 is equivalant to s21.

    Similarly s12 can be proved equivalant to s22. Hence s1 is equivalant to s2.

    I hope I’ve cleared your doubt. I ask you to please rate your experience here
    Your feedback is very important. It helps us improve our platform and hence provide you
    the learning experience you deserve.

    On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
    the doubt.