Description
Given strings s1, s2, and s3, find whether s3 is formed by interleaving s1 and s2. An interleaving maintains relative order of characters from both strings.
Examples
Input:
s1 = "aabcc", s2 = "dbbca", s3 = "aadbbcbcac"Output:
trueExplanation:
s3 can be formed by interleaving s1 and s2.
Input:
s1 = "aabcc", s2 = "dbbca", s3 = "aadbbbaccc"Output:
falseExplanation:
For s1 = "aabcc", s2 = "dbbca", s3 = "aadbbbaccc", the answer is false because the interleaving string condition is not met.
Input:
s1 = "abc", s2 = "", s3 = "abc"Output:
trueExplanation:
When one string is empty, s3 should exactly match the other non-empty string. Since s2 is empty, s3 must be formed by taking all characters from s1 in order, which it does.
Constraints
- •
0 ≤ s1.length, s2.length ≤ 100 - •
0 ≤ s3.length ≤ 200