python solution

class Solution(object):
def isInterleave(self, s1, s2, s3):
if len(s3) != len(s1) + len(s2) :
return False
last = set() # ((i,j) , (i2,j2))
last.add((-1,-1))
for i in range(len(s3)): # cal f(i)
tmp = set()
for (m,n) in last : #(i,j)
if m+1 <len(s1) and s3[i] == s1[m+1]:
tmp.add((m+1,n))
if n+1 <len(s2) and s3[i] == s2[n+1]:
tmp.add((m,n+1))
last = tmp
if not last:
return False
return True

for each char in s3 , we decide it is belong to s1 or s2 .

f(i) : record s3[0:i] nums of prefix in s1 and s2 ;

ex: s1"aabcc" s2"dbbca" s3: "aadbbcbcac"

f(0) = [(1,0) ] #s3[0] can only use 'a' in s1

f(1) = [(2,0)] # s3[0:2] can only use "aa " in s1

....

if f(i) == None this is f(i) can not interleaving of s1 and s2