请问触宝第一题哪里错了。指教
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
String[] str1 = new String[N];
for(int i = 0; i < N; i++) {
str1[i] = sc.next();
}
int M = sc.nextInt();
String[] str2 = new String[N];
for(int i = 0; i < M; i++) {
str2[i] = sc.next();
}
int count = 0;
for(int i = 0; i < M; i++) {
for(int j = 0; j < N; j++) {
if( LCS(str1[j], str2[i]) == str2[i].length() ) {
count++;
}
}
System.out.print(count);
if(i<N-1) {
System.out.println();
}
count = 0;
}
}
public static int LCS(String a, String b) {
int max = 0;
int[][] dp = new int[a.length()+1][b.length()+1];
for(int i = 1; i <= a.length(); i++) {
for(int j = 1; j <= b.length(); j++) {
if(a.charAt(i-1) == b.charAt(j-1)) {
dp[i][j] = dp[i-1][j-1] + 1;
} else {
dp[i][j] = 0;
}
max = Math.max(max, dp[i][j]);
}
}
return max;
}
}