Invalid test case!


#1

abbbcbaaccacaacc
acaaaccabcabcbcb

How can these two strings be scremble of each other?

similarly for test “abc” and “bac” how could they be scrambled? In the question it is mentioned that we can swap only the two child of the root!


#2

It’s not just two child of the root, It’s two child of any non-leaf node can be swaped.


#3

@IronMan007 Even considering what you said ‘abc’ cannot be scrambled to ‘bac’.

The above testcase is invalid


#4
   ABC          
  /   \
 AB    C      BA    C
/ \
A  B

Swap A with B.


#5

abbbcbaaccacaacc
acaaaccabcabcbcb

for these you have to keep in mind that we can chop string into any two non empty parts and can wswap them.