Why this code is failing on only Test Case 0, and all others are passing…?
Code failing on test case 0
Two strings a and b of equal length are called equivalent in one of the two cases:
- They are equal.
- 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:
- a1 is equivalent to b1, and a2 is equivalent to b2
- a1 is equivalent to b2, and a2 is equivalent to b1
to check a1 and b1 are equivalent or not you have to check these conditions again
you have to use recursion for that
i hope you got the point
if not feel free to ask
check for this input
abcd
dcba
they are equivalent
a=“abcd”
b=“dcba”
a1=“ab” a2=“cd”,
b1=“dc” b2=“ba”
now check equivalence of a1 and b2
so now
a=“ab”
b=“ba”
a1=“a” a2=“b”
b1=“b” b2=“a”
hence they are equivalent
Oh okay,i got it now…Thank you for the explanation!
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.