添加字符(暴力模拟)
添加字符
import java.util.Scanner;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
char[] A = in.next().toCharArray();
char[] B = in.next().toCharArray();
int lenA = A.length;
int lenB = B.length;
int count = lenA;
for(int i = 0 ; i <= lenB - lenA ;i++) {
int t = 0;
for(int j = 0; j < lenA; j++) {
if(A[j] != B[i + j]) {
t++;
}
}
count = Math.min(count,t);
}
System.out.print(count);
}
}