Skip to content

Commit 76a1f68

Browse files
committed
Time: 39 ms (74.51%), Space: 17.4 MB (20.18%) - LeetHub
1 parent 8195cc6 commit 76a1f68

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Solution:
2+
def isInterleave(self, s1: str, s2: str, s3: str) -> bool:
3+
n1=len(s1)
4+
n2=len(s2)
5+
n3=len(s3)
6+
@cache
7+
def isInter(i1,i2,i3):
8+
if i1==n1 and i2==n2 and i3==n3:
9+
return True
10+
11+
return i3<n3 and (i1<n1 and s1[i1]==s3[i3] and isInter(i1+1,i2,i3+1) or i2<n2 and s2[i2]==s3[i3] and isInter(i1,i2+1,i3+1))
12+
13+
return isInter(0,0,0)

0 commit comments

Comments
 (0)