python, 遍历一遍即可, 与最长公共子串的题一样,只不过输出的是长度而不是子串本身
公共子串计算
http://www.nowcoder.com/questionTerminal/98dc82c094e043ccb7e0570e5342dd1b
while True: try: a = input() b = input() if len(a) > len(b): a,b = b,a max_length = 0 i = 0 while i + max_length < len(a): while i + max_length < len(a) and a[i:i + max_length + 1] in b: max_length += 1 i += 1 print(max_length) except: break