码迷,mamicode.com
首页 > 编程语言 > 详细

[ Python ] KMP Algorithms

时间:2018-05-18 15:38:44      阅读:174      评论:0      收藏:0      [点我收藏+]

标签:def   tar   div   lse   Fix   ram   str   algorithm   table   

 1 def pmt(s):
 2     """
 3     :param s: the string to get its partial match table
 4     :return: partial match table
 5     """
 6     prefix = [s[:i + 1] for i in range(len(s) - 1)]
 7     suffix = [s[i + 1:] for i in range(len(s) - 1)]
 8     intersection = set(prefix) & set(suffix)
 9     if intersection:
10         return len(max(intersection))
11     else:
12         return 0
13 
14 def kmp(source, target):
15     for i in range(len(source)):
16         pass

 

[ Python ] KMP Algorithms

标签:def   tar   div   lse   Fix   ram   str   algorithm   table   

原文地址:https://www.cnblogs.com/coder211/p/9055977.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!