给出两个字符串,找到最长公共子串,返回其长度
参考代码:
class Solution: def longSubstring(self, A, B): ans = 0 for i in range(len(A)): for j in range(len(B)): l = 0 while i + 1 < len(A) and j + 1 < len(B) and A[i+1] == B[j+1]: l += 1 if l > ans: ans = 1 return ans