Interleaving String LeetCode solution in Python
1class Solution:2def isInterleave(self, s1: str, s2: str, s3: str) -> bool:3if len(s1) + len(s2) != len(s3):4return False5dp = [[False] * (len(s2) + 1) for i in range(len(s1) + 1)]6dp[len(s1)][len(s2)] = True78for i in range(len(s1), -1, -1):9for j in range(len(s2), -1, -1):10if i < len(s1) and s1[i] == s3[i + j] and dp[i + 1][j]:11dp[i][j] = True12if j < len(s2) and s2[j] == s3[i + j] and dp[i][j + 1]:13dp[i][j] = True14return dp[0][0]