"传送门" 求两个字符串最长公共子串的长度。 对于第一个串S,建立SAM,之后对于第二个串T,我们在上面和S进行匹配。首先从$t_0$开始,如果能成功匹配的话,那么我们让长度+1,同时更新答案。如果失配,那我们就跳parent树转移到其父节点的位置,并且把当前匹配长度变为其最长后缀长度即可。 最后统 ...
分类:
其他好文 时间:
2019-01-12 22:49:17
阅读次数:
222
Given a (singly) linked list with head node root, write a function to split the linked list into k consecutive linked list "parts". The length of each ...
分类:
其他好文 时间:
2019-01-12 21:00:12
阅读次数:
121
什么是最长递增子序列(Longest Increasing Subsquence) 对于一个序列{3, 2, 6, 4, 5, 1},它包含很多递增子序列{3, 6}, {2,6}, {2, 4, 5}, {1} 其中最长的递增子序列是{2, 4, 5} 问题:对于长度为N的矢量D,如何找到它的最长 ...
分类:
编程语言 时间:
2019-01-12 20:54:24
阅读次数:
229
Unlucky year in Berland is such a year that its number n can be represented as n?=?xa?+?yb, where a and b are non-negative integer numbers. For exampl ...
分类:
其他好文 时间:
2019-01-11 22:14:10
阅读次数:
165
class Solution { public String longestCommonPrefix(String[] strs) { if(strs == null || strs.length ...
分类:
其他好文 时间:
2019-01-11 17:17:01
阅读次数:
161
$\color{ 0066ff}{ 题目描述 }$ 题面描述 给定一些字符串,求出它们的最长公共子串 输入格式 输入至多$10$ 行,每行包含不超过$100000$ 个的小写字母,表示一个字符串 输出格式 一个数,最长公共子串的长度 若不存在最长公共子串,请输出$0$ 。 $\color{ 0066 ...
分类:
其他好文 时间:
2019-01-10 21:54:03
阅读次数:
181
$\color{ 0066ff}{ 题目描述 }$ 输入2 个长度不大于250000的字符串,输出这2 个字符串的最长公共子串。如果没有公共子串则输出0 。 $\color{ 0066ff}{输入格式}$ 两个字符串 $\color{ 0066ff}{输出格式}$ 一个整数,为 所求答案 $\col ...
分类:
其他好文 时间:
2019-01-10 19:30:34
阅读次数:
153
class Solution { public int lengthOfLongestSubstring(String s) { int res = 0; int left = 0, right = 0; int counter = 0; Map map = new HashMap(); while ...
分类:
其他好文 时间:
2019-01-10 13:20:19
阅读次数:
115
An integer interval [a, b] (for integers a < b) is a set of all consecutive integers from a to b, including a and b. Find the minimum size of a set S ...
分类:
其他好文 时间:
2019-01-09 23:36:44
阅读次数:
333
字符串遍历,从中间分出奇数回文和偶数回文两种情况不断更新长度。我一开陷入入误区把字符串分为奇偶结果偶数的可以过,基数的abb过不了。所以就是分析回文就好 ...
分类:
其他好文 时间:
2019-01-05 21:39:40
阅读次数:
193