Given strings s1, s2, and s3, return true if s3 is an interleaving of s1 and s2. Every character from s1 and s2 must be used exactly once, while preserving the order inside each source string. Pattern focus: Interleaving strings. This is the standard 2D DP formulation of the interleaving check.
s1 = first string, s2 = second string, s3 = target string
true if s3 can be formed by interleaving s1 and s2
Example 1:
Input:
s1 = "abc" s2 = "def" s3 = "adbcef"
Output:
true
Explanation:
Characters from both strings are interwoven while preserving order.
Example 2:
Input:
s1 = "abc" s2 = "def" s3 = "abdecf"
Output:
false
Explanation:
The character order from the source strings is violated.