import java util Scanner Created by alex on 23 05 14 public class KMP

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import java.util.Scanner;
/**
* Created by alex on 23.05.14.
*/
public class KMP {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String string = scanner.next();
String pattern = scanner.next();
String result = pattern + "$" + string;
}
public static void proccess(String s) {
int[] prefixValues = new int[s.length()];
prefixValues[0] = 0;
int currentChar = 1;
for (int i = 1; i < s.length(); i++) { // n + m
int j = prefixValues[i - 1];
while (j > 0 && s.charAt(i) != s.charAt(j)) { //m - 1
j = prefixValues[j - 1];
}
if (s.charAt(i) == s.charAt(j)) {
prefixValues[i] = j + 1;
}
}
for (int i : prefixValues) {
System.out.print(i + " ");
}
}
}