这题要求两个串中的最长相同子串的长度。高度数组可以求一个串中的最长相同子串的长度。所以想到把两个串连起来,但是这样又会产生一些新的串(第一个串的结尾和第二个串的开头组成的)于是在两个串中间放一个'\0'分隔,正好'\0'是字符里最小的,不会对第一个串的排序产生影响。 ...
分类:
编程语言 时间:
2019-01-27 16:39:03
阅读次数:
187
Write a function to find the longest common prefix string amongst an array of strings. If there is no common prefix, return an empty string "". Exampl ...
分类:
其他好文 时间:
2019-01-26 22:04:03
阅读次数:
171
Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000. Example 1: Example 2: 还是用DP来递归,抓住回 ...
分类:
其他好文 时间:
2019-01-26 21:38:37
阅读次数:
150
[toc] 题目链接 "Longest Common Prefix LeetCode" 注意点 考虑输入的字符串没有和只有一个的情况。 解法 解法一:先比较两个字符串得到他们的最长相同前缀,这就是答案就会是其他字符串和这个最长相同前缀的最长相同前缀。时间复杂度为O(nm) class Solutio ...
分类:
其他好文 时间:
2019-01-26 15:27:24
阅读次数:
211
Write a function to find the longest common prefix string amongst an array of strings. If there is no common prefix, return an empty string "". Exampl ...
分类:
其他好文 时间:
2019-01-26 11:08:27
阅读次数:
131
QueryString = { data: {}, Initial: function() { var aPairs, aTmp; var queryString = new String(window.location.search); queryString = queryString.subs ...
分类:
Web程序 时间:
2019-01-25 22:51:09
阅读次数:
239
最长公共子串 lcs.cpp/.in/.out 计算两个字符串的最大公共子串(Longest Common Substring)的长度,字符不区分大小写,这里的最大公共子串要求的字串是连续的。 输入: 两行,每行一个字符串,字符串长度<=1000. 输出: 输出一个整数,表示公共子串的长度。 样例输 ...
分类:
其他好文 时间:
2019-01-25 19:21:19
阅读次数:
182
Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000. Example 1: Input: "babad" Output: ...
分类:
其他好文 时间:
2019-01-25 11:34:43
阅读次数:
173
传送门:点我 978. Longest Turbulent Subarray 978. Longest Turbulent Subarray A subarray A[i], A[i+1], ..., A[j] of A is said to be turbulent if and only if: ...
分类:
编程语言 时间:
2019-01-23 23:25:39
阅读次数:
317
手动博客搬家: 本文发表于20181217 23:54:35, 原地址 https://blog.csdn.net/suncongbo/article/details/85058680 人生第一道后缀自动机。 说实话SAM我还没学多么明白。 但是题还是要做的。 说起来这玩意真的很妙。可惜我智商低理解 ...
分类:
其他好文 时间:
2019-01-23 21:37:49
阅读次数:
252