# Definition of interleave on test examples

• The example says:
s1 "aabcc"
s2 "dbbca"

if we decompose: s3
"aa"   "db"  "bc"  "bc"  "a"  "c"
s1     s2    s1    s2   s2    s1

It is not interleaving right?

• You are somewhat correct, in that the decomposition you gave is not interleaving.
On the other hand, the pattern

s1 = aa-bc-c
s2 = dbbc-a

does work.

aa   dbbc   bc   a  c
s1 -  s2  - s1 -s2 -s1

Interleaving does not mean that the segments must be the same length, only that by advancing in one string at a time, we can recreate s3.

• why the case above is not interleaving? could you explain more?

My understanding is as long as S3 is composed with S1, and S2 without reverse order, it should be OK. ("bc" "a" ) in S2 = :"bca", right?

or it must be S1-s2 -s1-s2?
can it be s2-s1-s2-s1?

• if we decompose : s3

"aa" "db" "bc" "bca" "c"
s1   s2   s1    s2   s1

the example is interleave.

• This really helps! Thank you

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.