-->
当前位置:首页 > 题库

PROGRAMMING:[template] KMP string matching

Luz5年前 (2021-05-10)题库406
Give two strings text and pattern, where pattern is the substring of text, find out all the positions of pattern in text.
In order to reduce cheating, next is the prefix array of substring.
###Input format:
The first line is a string, which is text.
The second line is a string, which is called pattern.
###Output format:
Several lines, each containing an integer, indicating the position of pattern in text.
The next line, including length (pattern) integers, represents the value of prefix array next [i]. The data is separated by a space, and there is no extra space at the end of the line.
###Input example:
```in
ABABABC
ABA
```
###Output example:
```out
one
three
0 0 1
```
###Example description:
![ snap650.jpg](~/05ffd584-7ab1-46eb-b717-79b180eac834.jpg)







answer:If there is no answer, please comment