LCS 模板代码
import java.util.Scanner;
/**
* @author Fanqingle
* Created by Administrator on 2022-05-06 03:55
*/
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String string = sc.nextLine();
String subString = sc.nextLine();
System.out.println(LCS(string, subString));
}
public static int LCS (String str1,String str2){
String result = "";
int start = 0,end =1;
while(end <= str2.length()){
String subStr = str2.substring(start,end);
if(str1.contains(subStr)){
result = subStr;
}else{
start++;
}
end ++;
}
return result.length();
}
}