The example shows the case where left child ALWAYS has equal or one-less characters than right child. But since "abb" is a scramble of "bab", as suggested by a test case, strings are not always partitioned in the way as the example implies.
However, if the answer is Yes, I think scrambles just become permutations. Isn't it?
So I am so confused what is expected...
Hi, I'm also confused. I just wonder if scramble has transitivity.
Since ABCDE => BACDE => BCADE => CABDE => CAEBD.
By the way, it says we can do the swap any times.
This is very important to understand the difference to come up with a solution for this problem.
you can not generate all the permutations of s1 with only branch and swap of the branches.
Permutation is like a grammar which is able to generate all the combinations while the branch and swap is like a push-down automata. The set of output strings will not be equal.
It will be much clear if the problem could describe how we can partition a String with an odd length.
Inferring from the example, I arrived at the wrong under assumption that length of the left child can not be greater than that of its sibling, right child.
when you swap AB with C then you can't swap BD with E . you can draw a tree on the paper ..
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.