Hello ah, I am gray little ape, a super will write bug program ape!

Welcome to my column.”The daily blue bridge”, the main role of this column is to share with you in recent years blue bridge cup provincial competition and the final and other real questions, analysis of the existing algorithm ideas, data structure and other content, to help you learn more knowledge and technology!

Title: Maximum common substring

The maximum common substring length problem is:

Find the maximum length that can be matched between all the substrings of two strings.

For example: “abCDKKk” and “baabcdadABC “,

The longest common substring you can find is “abcd”, so the maximum common substring length is 4.

The following procedure is to use the matrix method to solve, which is a relatively effective solution for the small size of the string.

public class Main {
	
	static int f(String s1,String s2) {
		char[] c1 = s1.toCharArray();
		char[] c2 = s2.toCharArray();
		
		int [][]a = new int[c1.length+1][c2.length+1];

		int max = 0;

		for (int i = 1; 
Copy the code