Interleaving String
Given strings s1, s2, and s3, determine if s3 is formed by interleaving s1 and s2 while preserving their relative order.

30:00

Interleaving String
medium
Topics
Companies

Given strings s1, s2, and s3, determine if s3 is formed by interleaving s1 and s2 while preserving their relative order.

Example 1:
Input: {"s1":"aabcc","s2":"dbbca","s3":"aadbbcbcac"}
Output: true
Constraints:
  • 0s1.length,s2.length1000 \leq s_1.\text{length}, s_2.\text{length} \leq 100

  • s3.length==s1.length+s2.lengths_3.\text{length} == s_1.\text{length} + s_2.\text{length}

  • s1,s2,s3s_1, s_2, s_3 consist of lowercase English letters.

Input
arr ={"s1":"aabcc","s2":"dbbca","s3":"aadbbcbcac"}

Initialize DP with base cases

dbbcaTFFFFFaTFFFFFaTFFFFFbFFFFFFcFFFFFFcFFFFFF
Variables
VariableValue
m5
n5
DepthFunction Call
Stack empty
0/26