京东算法字符串匹配通过25%,不知道哪里错了
T=input() S=input() def gggg(l1,l2): l=0 r=len(l1)-1 while l<r: t1 = l1[l]-l1[r] t2 = l2[l]-l2[r] l+=1 r-=1 if t1!=t2: return 0 return 1 def getMatch(A,B): aa = bytes(A,encoding='utf-8') bb = bytes(B,encoding='utf-8') if len(aa)<len(bb): temp =aa aa=bb bb=temp num=0 for i in range(len(aa)-len(bb)+1): cc=[] print(i,aa[i]) for j in range(len(bb)): cc.append(aa[i+j] + bb[j]) if gggg(cc,bb)==1: num+=1 return num getMatch(S,T) # print(gggg(b"aba",b'cyx'))#京东##笔试题目#