Invalid test case!



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!


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


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

The above testcase is invalid

  /   \
 AB    C      BA    C
/ \
A  B

Swap A with B.



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