题目描述:求一个字符串的不含重复字符的最长连续子串的长度; 思路: 1. 使用一个哈希表保存字符出现的位置; 2. 使用left和right分别表示子串的最左和最右字符的下标; 3. 遍历字符串,如果当前字符在哈希表中并且当前字符在哈希中的位置大于left,表明left和right之间存在和righ ...
分类:
编程语言 时间:
2017-12-08 01:21:15
阅读次数:
166
Given a string, find the length of the longest substring without repeating characters. Examples: Given "abcabcbb", the answer is "abc", which the leng ...
分类:
其他好文 时间:
2017-12-07 21:05:32
阅读次数:
129
题链: http://poj.org/problem?id=2774 题解: 求两个字符串(S,T)的最长公共子串。对 S串建后缀自动机。接下来就用这个自动机去求出能和 S串匹配的 T的每一个前缀的最长的后缀。最终答案就是对每个 T的前缀得到的答案取最大值就好了。 代码: #include #inc... ...
分类:
其他好文 时间:
2017-12-05 18:44:14
阅读次数:
126
Given a 01 matrix M, find the longest line of consecutive one in the matrix. The line could be horizontal, vertical, diagonal or anti-diagonal. Exampl ...
分类:
其他好文 时间:
2017-12-05 14:25:03
阅读次数:
209
思路:看到题目首先想到最大字符串匹配KMP算法 参考后代码 ...
分类:
其他好文 时间:
2017-12-04 21:23:31
阅读次数:
225
Bamboo and the Ancient Spell 分析 可能英文读题难度比较大,但是只要看到全大写的 "THE LONGEST COMMON SUBSEQUENCE !"应该就清楚这是考什么的了。 最长公共子序列:可以不连续。序列长度很大时,暴力方法非常费时,这也是一道比较经典的《算法导论》 ...
分类:
编程语言 时间:
2017-12-04 19:11:37
阅读次数:
180
A numeric sequence of ai is ordered if a1 < a2 < ... < aN. Let the subsequence of the given numeric sequence ( a1, a2, ..., aN) be any sequence ( ai1, ...
分类:
其他好文 时间:
2017-12-03 21:00:07
阅读次数:
160
You're given a string of lower-case Latin letters. Your task is to find the length of its longest substring that can be met in the string at least twi ...
分类:
其他好文 时间:
2017-12-03 19:55:20
阅读次数:
163
题目地址: https://leetcode.com/problems/longest-palindromic-substring/description/ 题目: 其实就是求一个字符串的最长回文子字符串。 解法: 我首先采取了暴力解法,不出意料地TLE了。这是超时的TLE解法: 这类题目一看就是用 ...
分类:
其他好文 时间:
2017-12-03 18:08:43
阅读次数:
134
Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000. Example: Example: 题目描述:给定字符串,求出最大的 ...
分类:
其他好文 时间:
2017-12-03 17:12:36
阅读次数:
111