要求:求两个字符串的最长公共子串,如“abcdefg”和“adefgwgeweg”的最长公共子串为“defg”(子串必须是连续的) public class Main03{ // 求解两个字符号的最长公共子串 public static String maxSubstring(String strOne, String strTwo){ // 参数检查 if(strOne==null || strTwo == null){ return null; } if(strOne.equals("&qu…
Long Long Message Time Limit: 4000MS   Memory Limit: 131072K Total Submissions: 31904   Accepted: 12876 Case Time Limit: 1000MS Description The little cat is majoring in physics in the capital of Byterland. A piece of sad news comes to him these days…
Freedom of Choice URAL - 1517 Background Before Albanian people could bear with the freedom of speech (this story is fully described in the problem "Freedom of speech"), another freedom - the freedom of choice - came down on them. In the near fu…
5. 查找两个字符串中含有的最长字符数的公共子串. package chapter5; import java.util.Scanner; public class demo5 { public static void main(String[] args) { Scanner sc=new Scanner(System.in); String a=sc.next(); String b=sc.next(); int max=0; int maxi=0; int arr[][]=new int[…
这个是华为OJ上的一道题目.首先,如果我们用java写代码,华为OJ有以下三条规则需遵守,否则编译无法通过或者用例无法通过,规则如下: (1)一定不可以有包名: (2)主类名只能为Main: (3)不可以输出与结果无关的信息. 好了,按照以上规则,我们写出来的代码如下(此代码不是最优的,只是用来记录华为OJ上java代码的书写规则): import java.util.Scanner; public class Main { public static void main(String[] ar…
把s1,s2拼接,求Height.相邻的Height判断左右串起点是否在两个串中,另外对Height和s1.length()-SA[i-1]取min. #include <iostream> #include <cstring> #include <string> #include <queue> #include <vector> #include <map> #include <set> #include <st…
http://tianyunpu2008.blog.163.com/blog/static/6559379920089162236915/…
1811. Longest Common Substring Problem code: LCS A string is finite sequence of characters over a non-empty finite set Σ. In this problem, Σ is the set of lowercase letters. Substring, also called factor, is a consecutive sequence of characters occur…
题目链接:https://vjudge.net/problem/POJ-2774 Long Long Message Time Limit: 4000MS   Memory Limit: 131072K Total Submissions: 33144   Accepted: 13344 Case Time Limit: 1000MS Description The little cat is majoring in physics in the capital of Byterland. A…
问题:有两个字符串str1和str2,求出两个字符串中最长公共字符串. 例如:“acbbsdef”和"abbsced"的最长公共字符串是“bbs” 算法思路: 1.把两个字符串分别以行和列组成一个二维矩阵. 2.比较二维矩阵中行和列对应的每个点的字符是否相同,是设置这个点为1,否设置这个点为0. 3.通过查找值为1的最长对角线来找到最长公共字符串. 通过上面str1和str2两个字符串,分别得出以行和列组成的一个二维矩阵如下图: 从上图可以看到,str1和str2共有3个公共子串&qu…