Manacher算法是个解决Palindrome问题的O(n)算法,可以说是个超级算法了,秒杀其他一切Palindrome解决方案,包括复杂的后缀数组。
网上很多解释,这里总结一下思想重点:
1 原字符串的字符间插入新的字符, 如#,方便统一所有的字符中心,比如aa和aba的字符中心不一样的,aa的字符中心可以说是aa,而aba的中心则是b,而插入#之后,aa成#a#a#,其中...
分类:
其他好文 时间:
2014-07-31 03:04:15
阅读次数:
224
Round Numbers
Time Limit: 2000MS
Memory Limit: 65536KB
64bit IO Format: %I64d & %I64u
[Submit] [Go Back]
[Status]
Description
The cows, as you know, have no...
分类:
其他好文 时间:
2014-07-31 00:08:55
阅读次数:
350
Description
The Fibonacci sequence is the sequence of numbers such that every element is equal to the sum of the two previous elements, except for the first two elements f0 and f1 which are respect...
分类:
其他好文 时间:
2014-07-31 00:08:05
阅读次数:
281
问题描述:
Given two integers n and k, return all possible combinations of k numbers out of 1 ... n.
For example,
If n = 4 and k = 2, a solution is:
[ [2,4], [3,4], [2,3], [1,2], [1,3], [1,4],]
解题思路...
分类:
其他好文 时间:
2014-07-31 00:04:35
阅读次数:
204
题目描述 Give you a lot of positive integers, just to find out how many prime numbers there are.. In each case, there is an integer N representing the num...
分类:
其他好文 时间:
2014-07-30 23:35:35
阅读次数:
300
Fibonacci Numbers
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1766 Accepted Submission(s): 695
Problem Description
The Fibon...
分类:
其他好文 时间:
2014-07-30 20:50:54
阅读次数:
276
题意:给你一个字符串,问你其中不重叠的回文字串对有多少解题思路:这题用到两种方法,不过其实是一个很巧妙的二重dp1)暴力求解以i开头,j结尾的是否为回文,如果是,ans += sum[i-1](ans 为答案, sum[i]为在 1 - i内回文串的个数--需要dp求解)这里非常耗时,时间大约为 n...
分类:
其他好文 时间:
2014-07-30 20:05:44
阅读次数:
276
Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number.An example is the root-to-leaf path 1->2->3 which...
分类:
其他好文 时间:
2014-07-30 11:30:33
阅读次数:
247
基本输入输出
5.1基本输出
print XXX //同一行输出
println XXX //换行输出
输出字符串:
def message ="My name is Michael"
println("here is :"+${message})
输出列表和映射
def numbers =[11,12,13,14]
println "Numbers:${nu...
分类:
其他好文 时间:
2014-07-30 10:08:13
阅读次数:
287