E-COM-NET
首页
在线工具
Layui镜像站
SUI文档
联系我们
推荐频道
Java
PHP
C++
C
C#
Python
Ruby
go语言
Scala
Servlet
Vue
MySQL
NoSQL
Redis
CSS
Oracle
SQL Server
DB2
HBase
Http
HTML5
Spring
Ajax
Jquery
JavaScript
Json
XML
NodeJs
mybatis
Hibernate
算法
设计模式
shell
数据结构
大数据
JS
消息中间件
正则表达式
Tomcat
SQL
Nginx
Shiro
Maven
Linux
palindrome
Leetcode:
Palindrome
Linked List
QuestionGivenasinglylinkedlist,determineifitisa
palindrome
.Followup:CouldyoudoitinO(n)timeandO(1)space
ayst123
·
2015-08-29 11:00
Leetcode -
Palindrome
Permutation II
Givenastrings,returnallthepalindromicpermutations(withoutduplicates)ofit.Returnanemptylistifnopalindromicpermutationcouldbeform.Forexample:Givens="aabb",return["abba","baab"].Givens="abc",return[].[分析
likesky3
·
2015-08-28 21:00
lightOJ 1205(Palindromic Numbers数位DP)
PalindromicNumbersTimeLimit:2000MSMemoryLimit:32768KB64bitIOFormat:%lld&%lluSubmitStatusDescriptionApalindromicnumberornumeral
palindrome
isa
ZSGG_ACM
·
2015-08-28 10:00
dp
lightoj
USACO-Section 1.5 Prime
Palindrome
s(Miller-Rabin)
描述因为151既是一个质数又是一个回文数(从左到右和从右到左是看一样的),所以151是回文质数。写一个程序来找出范围[a,b](5 #include #include usingnamespacestd; inta,b,num; boolwitness(longlonga,longlongn){ longlongd,x; d=1; inti=ceil(log(n-1.0)/log(2.0))
idealism_xxm
·
2015-08-27 21:00
USACO
miller-rabin
leetcode题解
structListNode{ *intval; *ListNode*next; *ListNode(intx):val(x),next(NULL){} *}; */ classSolution{ public: boolis
Palindrome
xtzmm1215
·
2015-08-27 21:00
Shortest
Palindrome
题意为,允许在字符串的头部添加字符,使其成为回文。最简单的方法是讲该字符串翻转为s2,s2+s1即为回文,但题目要求的是最短的回文串。于是问题便转换为一个,求以原字符串首字符开头(s[0])的最长子串的长度(亦即使得s.substr(0,length)为回文的最大length值)这么一个子问题。 ——可以想象,当求得这么一个length后,我们将s.substr(length)翻转添加到s头
u014674776
·
2015-08-27 17:00
LeetCode
C++
javascript判断回文数
在数学中也有这样一类数字有这样的特征,成为回文数(
palindrome
number)。 设n是一任意自然数。若将n的各位数字反向排列所得自然数n1与n相等,则称n为一回文数。
xflcx1991
·
2015-08-27 09:00
POJ 1159
Palindrome
(DP LCS&滚动数组)
DescriptionA
palindrome
isasymmetricalstring,thatis,astringreadidenticallyfromlefttorightaswellasfromrighttoleft.Youaretowriteaprogramwhich
Grit_ICPC
·
2015-08-25 11:00
dp
POJ3280--Cheapest
Palindrome
题目大意:给出一个长为m的字符串,可以添加删除n个字母,添加和删除的花费不一样。求使字符串变为回文串的最小花费。 分析:状态:dp[i][j]表示将原字符串的子串s[i...j]变为回文串的最小花费。注意增加和删除其实是一个障眼法,当在首尾增加一个字符使得一个字符串变成回文的话,那么删除一个也可以,这样自然是取增加删除的花费最小值状态转移方程:dp[i][j]=min(dp[i+1][j]+c[s
hhhhhhj123
·
2015-08-24 21:00
leetocde——
Palindrome
Number
这个题在leetcode上提示如下:Couldnegativeintegersbe
palindrome
s?
wikison
·
2015-08-24 14:00
最长回文 (hdu3068 && poj3974)
Palindrome
最长回文TimeLimit:4000/2000MS(Java/Others) MemoryLimit:32768/32768K(Java/Others)TotalSubmission(s):11771 AcceptedSubmission(s):4315ProblemDescription 给出一个只由小写英文字符a,b,c...y,z组成的字符串S,求S中最长回文串的长度.回文就是正
u010579068
·
2015-08-23 16:00
最长回文
palindrome
Manacher
hdu3068
poj3974
POJ 1159 && HDU 1513
Palindrome
(LCS)
Description给你一个字符串,可在任意位置添加字符,最少再添加几个字符,可以使这个字符串成为回文字符串Input第一行一个整数n表示字符串长度(n #include #include #include usingnamespacestd; #defineINF(1<<29) #definemaxn5005 chars1[maxn],s2[maxn]; intn; intdp[2][maxn
V5ZSQ
·
2015-08-23 14:00
Gym 100676F
Palindrome
(并差集)
codeforces.com/gym/100676/attachments/download/3333/acm-arabella-collegiate-programming-contest-en.pdf题目:F-F.
Palindrome
hellohelloC
·
2015-08-23 13:00
URAL 1989 Sub
palindrome
s(线段树单点修改+字符串hash)
题意:给出一个字符串,长度为105,有m个操作m#include#include#definels(o>1;build(lson);build(rson);pushUp(o,L,R);}voidmodify(into,intL,intR,intpos,intop){if(L==R){if(op==-1)lsum[o]=idx(str[L]);elsersum[o]=idx(str2[L]);ret
HelloWorld10086
·
2015-08-22 17:50
线段树
URAL 1989 Sub
palindrome
s(线段树单点修改+字符串hash)
题意:给出一个字符串,长度为105,有m个操作m #include #include #definels(o>1; build(lson); build(rson); pushUp(o,L,R); } voidmodify(into,intL,intR,intpos,intop){ if(L==R){ if(op==-1)lsum[o]=idx(str[L]); elsersum[o]=idx(
HelloWorld10086
·
2015-08-22 17:00
ural
1989
Leetcode -
Palindrome
Permutation
[分析]思路2让我大开眼界,顺便学习下BitSet~[ref]https://leetcode.com/discuss/53180/1-4-lines-python-ruby-c-c-java publicclassSolution{ //Method2:https://leetcode.com/discuss/53180/1-4-lines-python-ruby-c-c-java pub
likesky3
·
2015-08-22 16:00
Longest Palindromic Substring
char*longest
Palindrome
(char*s){ inti; intid=0,mx=0,imax=0; intp[2000]={0}; intlen=strlen(s); char*str
seeu
·
2015-08-21 22:00
UVA 401
Palindrome
s
Palindrome
sTimeLimit: 3000MS MemoryLimit: Unknown 64bitIOFormat: %lld&%lluSubmit StatusDescriptionAregular
palindrome
isastringofnumbersorlettersthatisthesameforwardasbackward.Forexample
qq_24653023
·
2015-08-21 14:00
ACM
uva
Codeforces 570E - Pig and
Palindrome
s (DP)
状态dp[cnt][x1][y1][x2][y2]表示左边从起点开始走cnt步到x1,y1,右边从终点开始走cnt步到x2,y2的方案数。因为知道cnt和x1,x2的话就能求出y1,y2,所以可以做个空间优化。但是这样还不够,因为cnt状态只和cnt-1状态有关,所以可以用滚动数组。转移方程就是当mp[x1][y1]==mp[x2][y2]时(mp为迷宫):dp[cnt][x1][x2]+=dp[
Baoli1008
·
2015-08-21 10:00
UVA 401-
Palindrome
s
水题细节也很重要啊。。。Inaddition,aftereachoutputline,youmustprintanemptyline.#include #include #include #include typedeflonglongll; usingnamespacestd; charconst*ch="AEHIJLMOSTUVWXYZ12358"; charconst*re="A3HILJM
Griffin_0
·
2015-08-20 10:00
leetcode——最长回文子串
显然这个算法的复杂度为O(n^2)class Solution { public: string longest
Palindrome
(string s) { //中心扩展法 int maxlen;
wikison
·
2015-08-20 09:00
poj1159(dp)
id=1159
Palindrome
TimeLimit:3000MSMemoryLimit:65536KTotalSubmissions:56628Accepted:19577DescriptionA
palindrome
isasymmetricalstring
随心丶而遇
·
2015-08-19 20:56
ACM—dp
Primes or
Palindrome
s?(打表+暴力枚举)
题目链接:codeforces568A题目大意:给出两个整数p,q,设A=pq,sum1[i]为≤i的素数的个数,sum2[i]为≤i的回文数的个数,问sum1[i]≤A⋅sum2[i]的最大的i是多少题目分析:首先通过线性筛将素数和回文数,然后暴力枚举即可。AC代码:#include #include #include #include #defineMAX2000007 usingnames
qq_24451605
·
2015-08-19 09:00
数论
codeforces
leetcode 细节实现题
解法1:classSolution{ public: boolis
Palindrome
(intx){ if(x=10)d*=10; while(x){ intp=x/d; intq=x%10; if(p
xtzmm1215
·
2015-08-18 23:00
Python解LeetCode 131:
Palindrome
Partitioning(Python中的浅复制与深复制)
LeetCode131:
Palindrome
PartitioningGivenastrings,partitionssuchthateverysubstringofthepartitionisa
palindrome
.Returnallpossible
palindrome
partitioningofs.Forexample
liuyuan185442111
·
2015-08-18 22:00
LeetCode
python
动态规划
DFS
【CF 570E】Pig and
Palindrome
s
【CF570E】Pigand
Palindrome
s三维dp找对应步数的组合数目二三维分别表示离1,1和n,m该步数的回文种类如果吧状态数都存下内存太大开个滚动dp数组(最近刚学的)代码如下:#include
ChallengerRumble
·
2015-08-18 21:00
dp
Codeforces Round #316 (Div. 2) E
E Pigand
Palindrome
s 一个n*m的网格,每个格子有一个字符,你需要从左上角走到右下角(只能往下或往右走),让经过的字符连起来是回文串,问有多少种方案。 dp。
squee_spoon
·
2015-08-18 21:00
codeforces
[LeetCode 234]
Palindrome
Linked List
Givenasinglylinkedlist,determineifitisa
palindrome
.Followup:CouldyoudoitinO(n)timeandO(1)space?
sbitswc
·
2015-08-18 14:00
LinkedList
pointer
Two
Pig and
Palindrome
s dp
E.Pigand
Palindrome
stimelimitpertest4secondsmemorylimitpertest256megabytesinputstandardinputoutputstandardoutputPeppathePigwaswalkingandwalkedintotheforest.Whatastrangecoincidence
u010422038
·
2015-08-17 17:00
Pig and
Palindrome
s (DP)
题目地址:http://codeforces.com/contest/570/problem/E比赛的时候急着睡觉这题没看。。。最显然的一个DP方法是dp[i][x1][y1][x2][y2]表示以s[x1][y1]和s[x2][y2]为第i步分别与s[1][1]和s[n][m]形成的回文串的个数,但是数组大小太大。。这时候可以发现知道步数后,y1和y2可以根据x1,x2来求出来,所以可以优化成d
u013013910
·
2015-08-17 15:00
编程
dp
ACM
算法与数据结构
【POJ 1159】
Palindrome
【POJ1159】
Palindrome
最近各种题各种奇葩思路已经司空见惯了。。。
ChallengerRumble
·
2015-08-17 14:00
dp+滚动数组
234
Palindrome
Linked List
题目要求在O(n)时间和O(1)空间内判断一个链表是不是回文的。先将链表分成2部分,然后反转其中一个,在进行比较。/***Definitionforsingly-linkedlist.*publicclassListNode{*intval;*ListNodenext;*ListNode(intx){val=x;}*}*/ publicclassSolution{ publicbooleanisP
taoxiuxia
·
2015-08-17 10:00
链表
回文
[LeetCode]
Palindrome
Partitioning
Palindrome
PartitioningGivenastring s,partition s suchthateverysubstringofthepartitionisa
palindrome
.Returnallpossible
palindrome
partitioningof
wangshaner1
·
2015-08-16 17:00
LeetCode
C++
Uva 401
Palindrome
s
Uva401
Palindrome
sAregular
palindrome
isastringofnumbersorlettersthatisthesameforwardasbackward.Forexample
qq_21120027
·
2015-08-15 21:00
uva
leetcode 字符串
classSolution{ public: boolis
Palindrome
(strings){ transform(s.begin(),s.end(),s.begin(),::tolower); autofirst
xtzmm1215
·
2015-08-15 01:00
判断一个字符串是否为回文串和镜像串(
Palindrome
s)
Aregular
palindrome
isastringofnumbersorlettersthatisthesameforwardasbackward.Forexample,thestring "ABCDEDCBA
Scarlett_geng
·
2015-08-14 17:00
字符串
uva
【LeetCode-面试算法经典-Java实现】【125-Valid
Palindrome
(回文字验证)】
【125-Valid
Palindrome
(回文字验证)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】原题Givenastring,determineifitisa
palindrome
derrantcm
·
2015-08-14 06:42
LeetCode
LeetCode
【LeetCode-面试算法经典-Java实现】【125-Valid
Palindrome
(回文字验证)】
【125-Valid
Palindrome
(回文字验证)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】原题Givenastring,determineifitisa
palindrome
DERRANTCM
·
2015-08-14 06:00
java
算法
面试
offer
回文字
【LeetCode-面试算法经典-Java实现】【125-Valid
Palindrome
(回文字验证)】
【125-Valid
Palindrome
(回文字验证)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】原题Givenastring,determineifitisa
palindrome
DERRANTCM
·
2015-08-14 06:00
java
算法
面试
offer
回文字
leetcode_
Palindrome
Linked List
描述:Givenasinglylinkedlist,determineifitisa
palindrome
.Followup:CouldyoudoitinO(n)timeandO(1)space?
dfb198998
·
2015-08-13 09:00
LeetCode
li
linked
palindrome
hdu 5340 Three
Palindrome
s(manachar)
题目链接:hdu5340Three
Palindrome
s用manachar处理一下,分别找出所有包括起始位置和终止位置的回文串,然后枚举第一个串和第三个串,判断中间剩下的是否是回文。
u011328934
·
2015-08-12 22:00
【杂题】CodeforcesRound #315 (Div. 2)569C Primes or
Palindrome
s?
题目链接题目大意:令g(x)表示x以内的素数个数,f(x)表示x以内回文数的个数。求最大的x使得g(x) #include #defineLLlonglongint #defineMAXN1200005 usingnamespacestd; LLphi[MAXN],b[MAXN],p,q; intnum[35]; boolflag[MAXN]; booljudge(intx){ intcnt=
cqbztsy
·
2015-08-12 21:00
codeforces
div-2
hdu-1513
Palindrome
Palindrome
TimeLimit:4000/2000MS(Java/Others) MemoryLimit:65536/32768K(Java/Others)TotalSubmission(
lljjccsskk
·
2015-08-12 20:00
周赛 Hdoj 5146
NerothinksanumbersequenceAisgoodonlyifthesumofitselementswithoddindexequalstothesumofitselementswithevenindexandthissequenceisnota
palindrome
just_sort
·
2015-08-12 19:00
leetcode Valid
Palindrome
C++&python 题解
题目描述Givenastring,determineifitisa
palindrome
,consideringonlyalphanumericcharactersandignoringcases.Forexample
xiaolewennofollow
·
2015-08-12 17:00
python
String
【POJ 3974】
Palindrome
【POJ3974】
Palindrome
Manacher纯模板题忘记的时候可以拿来找感觉代码如下:#include #include #include #include usingnamespacestd
ChallengerRumble
·
2015-08-12 14:00
Manacher
LeetCode题解:
Palindrome
Linked List
Givenasinglylinkedlist,determineifitisa
palindrome
.Followup:CouldyoudoitinO(n)timeandO(1)space?
u012403246
·
2015-08-12 10:00
LeetCode
leetcode 判断有效字符串是回文串Valid
Palindrome
Givenastring,determineifitisa
palindrome
,consideringonlyalphanumericcharactersandignoringcases.Forexample
yanerhao
·
2015-08-12 09:00
Manacher算法O(n) 时间复杂度求最长回文字串及其长度
原文地址:http://zhuhongcheng.wordpress.com/2009/08/02/a-simple-linear-time-algorithm-for-finding-longest-
palindrome
-sub-string
wr132
·
2015-08-12 09:00
on
回文
字串
manacher算法
最长
CodeForces #315 (div1) A.Primes or
Palindrome
s?
题目大意:求出最大的n,使得小于等于n的素数的个数 #defineLLlonglong usingnamespacestd; constintN=8000005,mx=8000000; boolnp[N]; intp[N],pcnt,sum[N]; inlineintget(intx){ inty=0; for(intt=x;t;t/=10){ (y*=10)+=t%10; } returnx==
qq919017553
·
2015-08-12 00:00
上一页
75
76
77
78
79
80
81
82
下一页
按字母分类:
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
其他