Python Solution gives wrong answer


#1

Wts wrong with this python solution.
def numDistinct(self, A, B):
m=len(A)
n=len(B)
l=[[0 for i in range(m)]for j in range(n)]
for j in range(m):
l[0][j]=1
for i in range(1,n):
l[i][j]=0
for i in range(1,n):
for j in range(1,m):
if(B[i]!=A[j]):
l[i][j]=l[i][j-1]
elif(B[i]==A[j]):
l[i][j]=l[i][j-1]+l[i-1][j-1]
return (l[n-1][m-1])
It gives wrong answer for input-A : “aaaababbababbaabbaaababaaabbbaaabbb”
B : “bbababa”