class Solution:
"""
@param s1: A string
@param s2: A string
@param s3: A string
@return: Determine whether s3 is formed by interleaving of s1 and s2
"""
def isInterleave(self, s1, s2, s3):
# write your code here
j = 0
k = 0
for i in range(0,len(s3)):
if j < len(s1) and k < len(s2) and s1[j] == s3[i] and s1[j] == s2 [k]:
return self.isInterleave(s1[j+1:],s2[k:],s3[i+1:]) or self.isInterleave(s1[j:],s2[k+1:],s3[i+1:])
elif j < len(s1) and s1[j] == s3[i]:
j+=1
elif s2[k] == s3[i]:
k+=1
else:
return False
return True