在字符串s中寻找模式串p的位置,这是一个字符串匹配问题. 举例说明: i = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 s = a b a a c a b a a a b a a b p = a b a a b j = 0 1 2 3 4 在kmp算法发明之前.人们使用这种算法: ''' 原始的求子串位置算法,O( m * n ) ''' def string_index_of( pstr, pattern, pos = 0 ): str_index = pos patte…
HDU 1711 Number Sequence (字符串匹配,KMP算法) Description Given two sequences of numbers : a1, a2, ...... , aN, and b1, b2, ...... , bM (1 <= M <= 10000, 1 <= N <= 1000000). Your task is to find a number K which make aK = b1, aK+1 = b2, ...... , aK+M…