求最长回文子串: 回文串是指正着读和反过来读都一样的字符串。 方法: 1. 为了统一解题方法,避免字符串长度奇偶对解题方法的影响,加入了填充字符。若原来的字符串长度为n,则新的字符串长度为2n+1。 2. pos+p[pos] 表示的是目前所有回文子串中,向右达到的最远位置。 3. 先利用对称性,找 ...
分类:
其他好文 时间:
2016-08-31 00:45:22
阅读次数:
156
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 unique longes ...
分类:
其他好文 时间:
2016-08-29 09:05:52
阅读次数:
165
Given a string, find the length of the longest substring without repeating characters. Examples: Given "abcabcbb", the answer is "abc", which the leng ...
分类:
其他好文 时间:
2016-08-29 06:53:36
阅读次数:
139
题目: Given a string, find the length of the longest substring without repeating characters. Examples: Given "abcabcbb", the answer is "abc", which the ...
分类:
其他好文 时间:
2016-08-29 01:42:42
阅读次数:
141
Suppose we abstract our file system by a string in the following manner: The string "dir\n\tsubdir1\n\tsubdir2\n\t\tfile.ext" represents: The director ...
分类:
其他好文 时间:
2016-08-26 06:40:19
阅读次数:
384
求最长回文子串的裸题,搞竞赛的时候遇到过各种花样的变式。
n方的朴素算法已经烂大街了,推荐使用O(n)的算法,只可惜很久没用过manacher算法,不会写了,所以花了一段时间温故知新。
manacher算法原理不了解的道友可以看这篇文章:...
分类:
其他好文 时间:
2016-08-24 15:54:14
阅读次数:
167
Suppose we abstract our file system by a string in the following manner: The string "dir\n\tsubdir1\n\tsubdir2\n\t\tfile.ext" represents: The director ...
分类:
其他好文 时间:
2016-08-24 14:29:01
阅读次数:
192
Given two strings, find the longest common substring. Return the length of it. Example Given A = "ABCD", B = "CBCE", return 2. Given A = "ABCD", B = " ...
分类:
其他好文 时间:
2016-08-24 12:58:37
阅读次数:
145
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 unique longes ...
分类:
其他好文 时间:
2016-08-24 06:35:43
阅读次数:
197