题目描述 农夫FJ的农场是一个N*N的正方形矩阵(2\le N\le 5002≤N≤500),每一块用一个字母作标记。比如说: 某一天,FJ从农场的左上角走到右下角,当然啦,每次他只能往右或者往下走一格。FJ把他走过的路径记录下来。现在,请你把他统计一下,所有路径中,回文串的数量(从前往后读和从后往 ...
分类:
其他好文 时间:
2017-07-31 20:50:41
阅读次数:
205
Given a string, your task is to count how many palindromic substrings in this string. The substrings with different start indexes or end indexes are c ...
分类:
其他好文 时间:
2017-07-26 09:42:57
阅读次数:
114
Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000. Example: Example: Similar Question ...
分类:
其他好文 时间:
2017-07-25 14:21:47
阅读次数:
130
https://leetcode.com/problems/longest-palindromic-substring/#/description Given a string s, find the longest palindromic substring in s. You may assum ...
分类:
其他好文 时间:
2017-07-24 23:36:23
阅读次数:
153
Given a string, your task is to count how many palindromic substrings in this string. The substrings with different start indexes or end indexes are c ...
分类:
其他好文 时间:
2017-07-24 16:23:08
阅读次数:
155
select convert(datetime,substring(left('20170719172552',8)+' ' + substring('20170719172552',9,2)+':' + substring('20170719172552',11,2)+':' + substrin... ...
分类:
数据库 时间:
2017-07-20 21:00:02
阅读次数:
197
H. Special Palindrome A sequence of positive and non-zero integers called palindromic if it can be read the same forward and backward, for example: 15 ...
分类:
其他好文 时间:
2017-07-17 22:01:38
阅读次数:
179
考虑2-SAT建图,设$a[i][0..1]$表示$i$变不变,$b[i][0..1]$表示$i$是下降还是上升。 首先相邻的不能同时动,说明$a[i]$和$a[i+1]$里最多选一个。 对于$x$和$y$要相等,假设$s[x]\geq s[y]$。 $1.$若$s[x]-s[y]=3$,则视为$1 ...
分类:
其他好文 时间:
2017-07-16 09:56:46
阅读次数:
200
判断回文(recursive) 两个条件: string中*s.end() 是‘\0’. 不使用递归: 得到最长的子回文字符串,最简单的做法得到所有字符串是否回文,记录长度,比较得到最长的。 要进行两次循环,时间复杂度高。O(n^3); 改进中心扩展法: 字符串可能为奇数个或偶数个,奇数个时从一个中 ...
分类:
其他好文 时间:
2017-07-12 21:26:50
阅读次数:
135
1 const int MAXN = 100005 ; 2 const int N = 26 ; 3 4 struct Palindromic_Tree{ 5 int next[MAXN][N] ;//next指针,next指针和字典树类似,指向的串为当前串两端加上同一个字符构成 6 int fai ...
分类:
其他好文 时间:
2017-07-07 00:02:43
阅读次数:
196