题目意思:求字符串中,最长不重复连续子串思路:使用hashmap,发现unordered_map会比map快,设置一个起始位置,计算长度时,去减起始位置的值 eg:a,b,c,d,e,c,b,a,e 0 1 2 3 4 0 1 5 3 4 0 6 5 3 4 ...
分类:
其他好文 时间:
2015-06-18 16:43:21
阅读次数:
156
Quadratic primes
Problem 27
Euler discovered the remarkable quadratic formula:
n² + n + 41
It turns out that the formula will produce 40 primes for the consecutive values n = 0 to 39. Howe...
分类:
编程语言 时间:
2015-06-17 21:37:46
阅读次数:
149
题意:最长回文子串。原题来自:https://leetcode.com/problems/longest-palindromic-substring/分析:有2种解法,字符串解析(KMP算法,我忘了),还有一种,直接用动态规划搞定。不晓得动态规划方法的朋友,自己百度学下这方法,该方法用处很多。至于K...
分类:
其他好文 时间:
2015-06-17 21:16:07
阅读次数:
121
Given a stringS, find the longest palindromic substring inS. You may assume that the maximum length ofSis 1000, and there exists one unique longest pa...
分类:
其他好文 时间:
2015-06-17 15:16:35
阅读次数:
140
Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters fo...
分类:
其他好文 时间:
2015-06-17 14:57:56
阅读次数:
111
Manacher 算法是时间、空间复杂度都为 O(n) 的解决 Longest palindromic substring(最长回文子串)的算法。回文串是中心对称的串,比如 'abcba'、'abccba'。那么最长回文子串顾名思义,就是求一个序列中的子串中,最长的回文串。本文最后用 Python ...
分类:
编程语言 时间:
2015-06-16 20:49:30
阅读次数:
354
problem:Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one uniqu...
分类:
其他好文 时间:
2015-06-16 18:32:29
阅读次数:
113
题目描述:求两个输入序列的最长的公共子字符串的长度。子字符串中的所有字符在源字符串中必须相邻。如字符串:21232523311324和字符串312123223445,他们的最长公共子字符串为21232,长度为5。最长公共子串(Longest Common Substirng)和最长公共子序列(Lon...
分类:
其他好文 时间:
2015-06-16 16:32:26
阅读次数:
75
Consecutive sum IITime Limit: 3000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2523Accepted Submission(s): 1219...
分类:
其他好文 时间:
2015-06-15 23:47:50
阅读次数:
197
Given a string containing just the characters'('and')', find the length of the longest valid (well-formed) parentheses substring.For"(()", the longest...
分类:
其他好文 时间:
2015-06-15 13:04:56
阅读次数:
82