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
Substrings
Reverse
Substrings
Between Each Pair of Parentheses
题目如下:GivenastringsthatconsistsoflowercaseEnglishlettersandbrackets.Reversethestringsineachpairofmatchingparentheses,startingfromtheinnermostone.Yourresultshouldnotcontainanybracket.Example1:Input:s="(
seyjs
·
2019-09-17 10:00
回文子串(Palindromic
Substrings
)
Leetcode之动态规划(DP)专题-647.回文子串(PalindromicSubstrings)给定一个字符串,你的任务是计算这个字符串中有多少个回文子串。具有不同开始位置或结束位置的子串,即使是由相同的字符组成,也会被计为是不同的子串。示例1:输入:"abc"输出:3解释:三个回文子串:"a","b","c".示例2:输入:"aaa"输出:6说明:6个回文子串:"a","a","a","a
秦羽纶
·
2019-09-10 00:00
再说Java集合,subList之于ArrayList
publicstaticvoidtestSubList(){ListstringList=newArrayListsubstrings=stringList.subList(3,5);System.out.println(
substrings
.toString
工匠初心
·
2019-06-29 08:00
Palindromic
Substrings
题目描述:Givenastring,yourtaskistocounthowmanypalindromicsubstringsinthisstring.Thesubstringswithdifferentstartindexesorendindexesarecountedasdifferentsubstringseventheyconsistofsamecharacters.Example1:In
牛奶芝麻
·
2019-06-10 23:08
回文子串的数量(Palindromic
Substrings
)
Leetcode-647PalindromicSubstrings(Medium)Input:"aaa"Output:6Explanation:Sixpalindromicstrings:"a","a","a","aa","aa","aaa".解题思路:依次以每个字符为中心向外扩展,计算回文子串的数量。intcount=0;publicintcountSubstrings(Strings){for
str_818
·
2019-05-19 19:59
LeetCode
字符串
codefoces 1110 H:Modest
Substrings
(AC自动机,动态规划)
Youaregiventwointegerslandr.Let’scallanintegerxmodest,ifl≤x≤r.Findastringoflengthn,consistingofdigits,whichhasthelargestpossiblenumberofsubstrings,whichmakeamodestinteger.Substringhavingleadingzerosar
1035719430
·
2019-03-04 14:11
AC自动机
动态规划
Palindromic
Substrings
题目Givenastring,yourtaskistocounthowmanypalindromicsubstringsinthisstring.Thesubstringswithdifferentstartindexesorendindexesarecountedasdifferentsubstringseventheyconsistofsamecharacters.Example1:Input
liuqinh2s
·
2019-01-09 00:00
动态规划
字符串处理
算法
leetcode
Unique
Substrings
in Wraparound String
[leetcode]UniqueSubstringsinWraparoundString链接:https://leetcode.com/problems/unique-
substrings
-in-wraparound-string
Charles-Liu
·
2018-08-21 19:31
leetcode
动态规划
Count Binary
Substrings
题目地址:https://leetcode.com/problems/count-binary-
substrings
/description/大意:给定一个二进制数字构成的字符串,看有多少个包含0和1数目相同的子字符串
fred_33c7
·
2018-08-20 12:13
Palindromic
Substrings
Givenastring,yourtaskistocounthowmanypalindromicsubstringsinthisstring.Thesubstringswithdifferentstartindexesorendindexesarecountedasdifferentsubstringseventheyconsistofsamecharacters.Example1:Input:"
nafoahnaw
·
2018-03-15 22:29
C#Regex.Split 用法
publicclassExample{publicstaticvoidMain(){stringinput="plum--pear";stringpattern="-";//Splitonhyphensstring[]
substrings
b86130
·
2018-01-05 09:16
C#
Count Binary
Substrings
MediumGiveastrings,countthenumberofnon-empty(contiguous)substringsthathavethesamenumberof0'sand1's,andallthe0'sandallthe1'sinthesesubstringsaregroupedconsecutively.Substringsthatoccurmultipletimesarec
greatfulltime
·
2017-12-11 03:36
hihocoder #1445 : 后缀自动机二·重复旋律5
根据上周学习的SAM的基本概念和性质,SAM的每个状态st都包含了一部分S的子串,记作
substrings
(st),并且(1)对于两个不
但求-_-心安
·
2017-09-27 21:35
ACM-sam
Palindromic
Substrings
https://leetcode.com/problems/palindromic-
substrings
/description/Givenastring,yourtaskistocounthowmanypalindromicsubstringsinthisstring.Thesubstringswithdifferentstartindexesorendindexesarecountedasdi
议题一玩到
·
2017-09-18 02:00
leetcode
string
dp
linkedin
LeetCode
Palindromic
Substrings
找到字符串中的回文子序列的个数比如给定一个字符串“aaa”,它的子序列的个数就是a,a,a,aa,aa,aaa如果给定的是“abc”,那么它的子序列就是a,b,cstring[i]到string[j]这个子串是回文的可能性只有当string[i]==string[j]而且string[i+1]到string[j-1]是回文。但是考虑到如果中间只有一个字符时它一定是回文,所以我的判断条件写的是i+1
TonyYang1995
·
2017-08-29 01:03
LEETCODE
[leetcode] Unique
Substrings
in Wraparound String
467.UniqueSubstringsinWraparoundStringImplementatoitoconvertastringtoaninteger.Hint:Carefullyconsiderallpossibleinputcases.Ifyouwantachallenge,pleasedonotseebelowandaskyourselfwhatarethepossibleinputc
Jun.M
·
2017-05-29 04:00
Unique
Substrings
in Wraparound String 解题报告
Considerthestringstobetheinfinitewraparoundstringof"abcdefghijklmnopqrstuvwxyz",soswilllooklikethis:"...zabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcd....".Nowwehaveanotherstringp.Yourjobis
a921122
·
2017-04-03 05:24
LeetCode
[SPOJ8222]NSUBSTR -
Substrings
(后缀自动机)
题目描述传送门题意:定义f(i)为长度为i的子串的最多出现次数(可重复),求f(1…n)题解很显然f(1..n)不升,那么可以用f(i)=max{f(i),f(i+1)}right集合表示当前状态在哪里出现过,其实就是求right集合的大小主链上的所有的点right集合初始为1(因为它代表了原串的一个前缀)如果两个点的right集合有交集,那么一定一个是另一个的真子集所以在parent树上把儿子的
Clove_unique
·
2016-12-30 08:31
题解
后缀自动机
[POJ1226]
Substrings
(后缀数组+二分)
题目描述传送门题解这题不同的地方在于要判断是否在反转后的字符串中出现。其实这并没有加大题目的难度。只需要先将每个字符串都反过来写一遍,中间用一个互不相同的且没有出现在字符串中的字符隔开,再将n个字符串全部连起来,中间也是用一个互不相同的且没有出现在字符串中的字符隔开,求后缀数组。然后二分答案,再将后缀分组。判断的时候,要看是否有一组后缀在每个原来的字符串或反转后的字符串中出现。代码#include
Clove_unique
·
2016-12-27 23:21
题解
后缀数组
二分
[POJ3415]Common
Substrings
(后缀数组+单调栈)
题目描述传送门题意:给定两个字符串A和B,求长度不小于k的公共子串的个数(可以相同)。题解首先把一个串接在另一个串的后面,中间放一个没出现过的字符。由于每一个子串都是某一个后缀的前缀,求出sa和height了之后,我们可以将height分组,组内都是height>=k的后缀。可以知道长度不小于k的公共子串是两个后缀的前缀,并且它们一定在同一组内。那么对于每一组,从前往后扫,假设遇到了A的后缀,那么
Clove_unique
·
2016-12-26 21:13
题解
单调栈
后缀数组
Leetcode: Unique
Substrings
in Wraparound String
Considerthestringstobetheinfinitewraparoundstringof"abcdefghijklmnopqrstuvwxyz",soswilllooklikethis:"...zabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcd....". Nowwehaveanotherstringp.Yourjob
neverlandly
·
2016-12-22 11:00
[LeetCode] Unique
Substrings
in Wraparound String 封装字符串中的独特子字符串
Considerthestring s tobetheinfinitewraparoundstringof"abcdefghijklmnopqrstuvwxyz",so s willlooklikethis:"...zabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcd....".Nowwehaveanotherstring p.You
Grandyang
·
2016-12-07 22:00
最长公共子串(1)--hdu1238(多个字符串得最长公共子串--暴力)
Substrings
TimeLimit:1000MS MemoryLimit:32768KB 64bitIOFormat:%I64d&%I64uDescriptionYouaregivenanumberofcase-sensitivestringsofalphabeticcharacters
Sly_461
·
2016-08-25 16:46
HDU 1238
Substrings
(最长公共子串+DFS)
SubstringsTimeLimit:2000/1000MS(Java/Others) MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):9246 AcceptedSubmission(s):4388ProblemDescriptionYouaregivenanumberofcase-sensitivestringsofa
liangzhaoyang1
·
2016-06-03 13:00
DFS
HDU
Substrings
1238
HDU 1238
Substrings
题目链接:HDU1238SubstringsTimeLimit:2000/1000MS(Java/Others) MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):9192 AcceptedSubmission(s):4353ProblemDescriptionYouaregivenanumberofcase-sensiti
qq_29480875
·
2016-05-13 19:00
KMP
Different is Good __
substrings
water problem
B.DifferentisGoodtimelimitpertest2secondsmemorylimitpertest256megabytesinputstandardinputoutputstandardoutputAwisemantoldKerem"Differentisgood"once,soKeremwantsallthingsinhislifetobedifferent.Keremrec
ProLightsfxjh
·
2016-05-12 11:00
ACM
round
codeforces
Substrings
water
pro
#35
Count Good
Substrings
Wecallastringgood,ifaftermergingalltheconsecutiveequalcharacters,theresultingstringispalindrome.Forexample,"aabba"isgood,becauseafterthemergingstepitwillbecome"aba".Givenastring,youhavetofindtwovalues
u014258433
·
2016-05-08 21:00
ACM
好题
Codeforces 451D Count Good
Substrings
(组合数)
题意给出一个只有a和b的串求有多少个子串满足删去连续的重复字母之后是一个回文串,输出分为奇数长度和偶数长度的。思路只有两个字母这是个很重要的条件,这样的话一个子串只需要头和尾相同就可以删成一个回文串了。那就分别讨论一下就可以了:奇数长度的=C(2oddnumofa)+C(2oddnumofb)+C(2evennumofa)+C(2evennumofb)偶数长度的=oddnumofa∗evennum
Dreamon3
·
2016-05-08 19:00
codeforces
UVA 10829 L-Gap
Substrings
题意:形如UVU这种字符串,其中U、V都是字符串,V的长度为L,那么称此种字符串为L-GapString,要求的是一个字符串中有多少个子串为L-GapString。题解:网上有很多关于此题的题解,但是都只是说了怎么做的,并没有说为什么是这样。开始其实也不懂,后面写出来就好像懂了。大概说一下思路,首先用后缀数组求出lcp是很容易想到的,我们可以每次枚举U的长度L,那么就可以得到一个区间[i,i+L+
wsnbb123456789
·
2016-05-08 11:00
CSU 1632 Repeated
Substrings
(后缀数组)
Description求字符串中所有出现至少2次的子串个数Input第一行为一整数T(T #include #include #include #include usingnamespacestd; #definemaxn111111 intt1[maxn],t2[maxn],c[maxn],sa[maxn],Rank[maxn],height[maxn]; boolcmp(int*r,inta,
V5ZSQ
·
2016-05-03 14:00
SPOJ 694 Distinct
Substrings
(后缀数组)
Description给出一个字符串,求这个串不同的子串个数Input第一行为一整数T(T #include #include #include usingnamespacestd; #definemaxn1111 intt1[maxn],t2[maxn],c[maxn],sa[maxn],rank[maxn],height[maxn]; boolcmp(int*r,inta,intb,intl)
V5ZSQ
·
2016-05-03 14:00
POJ 3415 Common
Substrings
(后缀数组+单调栈)
Description给出两个串a和b,求a和b的长度不小于k的公共子串数量Input多组用例,每组用例第一行为一整数k,之后为两个字符串表示a和b,两个串的串长不超过10^5,k不超过两串串长,以k=0结束输入Output对于每组用例,输出a和b的长度不小于k的公共子串数量SampleInput2aababaaabaabaa1xxxx0SampleOutput225Solution将两串连在一起
V5ZSQ
·
2016-05-03 13:00
poj3415 Common
Substrings
(后缀数组+单调队列)
TimeLimit: 5000MS MemoryLimit: 65536KTotalSubmissions: 9414 Accepted: 3123DescriptionAsubstringofastring T isdefinedas:T(i, k)=TiTi+1...Ti+k-1,1≤i≤i+k-1≤|T|.Giventwostrings A, B andoneinteger K,wedefi
Kirito_Acmer
·
2016-04-30 17:00
后缀数组
单调队列
POJ1226:
Substrings
(后缀数组)
DescriptionYouaregivenanumberofcase-sensitivestringsofalphabeticcharacters,findthelargeststringX,suchthateitherX,oritsinversecanbefoundasasubstringofanyofthegivenstrings.InputThefirstlineoftheinputcon
lcchuguo
·
2016-04-20 10:00
hdu 1238
Substrings
(求子串或者他的逆序子串出现在每个字符串中)
SubstringsTimeLimit:2000/1000MS(Java/Others) MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):9003 AcceptedSubmission(s):4238ProblemDescriptionYouaregivenanumberofcase-sensitivestringsofa
acm_fighting
·
2016-04-06 11:00
SPOJ DISUBSTR - Distinct
Substrings
or SUBST1 - New Distinct
Substrings
【不同子串数目】
题目1链接:SPOJDISUBSTR-DistinctSubstrings题目1链接:SPOJSUBST1-NewDistinctSubstringsDISUBSTR-DistinctSubstringsnotagsGivenastring,weneedtofindthetotalnumberofitsdistinctsubstrings.InputT-numberoftestcases.T #i
chenzhenyu123456
·
2016-04-04 16:00
[SPOJ8222]NSUBSTR -
Substrings
NSUBSTR-SubstringsYouaregivenastringSwhichconsistsof250000lowercaselatinlettersatmost.WedefineF(x)asthemaximalnumberoftimesthatsomestringwithlengthxappearsinS.Forexampleforstring‘ababa’F(3)willbe2beca
hbhcy98
·
2016-04-04 11:00
后缀自动机
【SPOJ DISUBSTR】Distinct
Substrings
后缀数组
Givenastring,weneedtofindthetotalnumberofitsdistinctsubstrings.InputT-numberoftestcases.T #include #include #include usingnamespacestd; typedeflonglongLL; constintSZ=1000010; intlcp[SZ],sa[SZ],tmp[
LOI_DQS
·
2016-02-27 17:00
HDU 1238
Substrings
SubstringsTimeLimit:2000/1000MS(Java/Others)MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):8866AcceptedSubmission(s):4157ProblemDescriptionYouaregivenanumberofcase-sensitivestringsofalphabeti
ChiLuManXi
·
2016-02-23 13:11
spojDistinct
Substrings
【后缀数组 不重复子串】
DescriptionGivenastring,weneedtofindthetotalnumberofitsdistinctsubstrings.InputT-numberoftestcases.T #include #include usingnamespacestd; #defineMAXN10005 intt1[MAXN],t2[MAXN],c[MAXN]; boolcmp(int*r,i
zhou_yujia
·
2016-02-22 08:00
String
后缀数组
SPOJ705 SUBST1 - New Distinct
Substrings
(后缀数组)
给一个字符串求有多少个不相同子串。每一个子串一定都是某一个后缀的前缀。由此可以推断出总共有(1+n)*n/2个子串,那么下面的任务就是找这些子串中重复的子串。在后缀数组中后缀都是排完序的,从sa[1]到sa[n],这么思考以某个串为前缀的子串有几个,那么容易想到重复子串的个数其实就是∑height[i]。所以结果就是(1+n)*n/2-∑height[i]。1#include 2#include
WABoss
·
2016-02-20 16:00
HUST 1352 Repetitions of
Substrings
(字符串)
RepetitionsofSubstringsDescriptionThe“repetitions”ofastringS(whoselengthisn)isamaximumnumber“k”suchthat:1)kisafactorofn2)S[0..n/k-1]=S[p*(n/k)..(p+1)*(n/k)-1]forallthat(1 #include #include #include
ACMSaga
·
2016-02-18 13:00
spoj 8222
Substrings
(后缀自动机+DP)
SubstringsTimeLimit: 100MS MemoryLimit: 1572864KB 64bitIOFormat: %lld&%lluSubmit StatusDescriptionYouaregivenastringSwhichconsistsof250000lowercaselatinlettersatmost.WedefineF(x)asthemaximalnumberoft
hahalidaxin
·
2016-02-18 11:00
后缀数组:SPOJ SUBST1 - New Distinct
Substrings
Givenastring,weneedtofindthetotalnumberofitsdistinctsubstrings.InputT-numberoftestcases.T 2#include 3#include 4#include 5#include 6 7constintmaxn=50010; 8charS[maxn]; 9 10intr[maxn],wa[maxn],
TenderRun
·
2016-02-16 21:00
【SPOJ-SUBST1】New Distinct
Substrings
【后缀数组】
和http://blog.csdn.net/braketbn/article/details/50649595一样就是数据规模大了...但是还是照样过。#include #include #include #include usingnamespacestd; typedeflonglongLL; constintmaxn=50005,M=300; intsa[maxn],rank[max
BraketBN
·
2016-02-15 21:00
后缀数组
Lucky
Substrings
而在26以内且属于fibonacci数列的数为1,2,3,5,8,13,21时间限制:10000ms单点时限:1000ms内存限制:256MB描述Astringsis LUCKY ifandonlyifthenumberofdifferentcharactersinsisa fibonaccinumber.Givenastringconsistingofonlylowercaseletters,o
sjy22
·
2016-02-11 14:00
hihoCoder_W84 Lucky
Substrings
(基础做法)
【题目】点击这里【思路】分两步走,1.找出所有斐波那契子串;2.按字典序无重复地输出。第一步可以枚举子串,由于规模比较小,O(n^2)的算法都可以接受。O(n^3)优化至O(n^2)的方法是,从前往后枚举子串,[i…j+1]可以利用[i…j]的结果。第二步可以选择排序,然后无重复输出,也可以考虑建立字典树去重并排序,然后先序遍历输出。字典树的方法将在下周贴上来。【代码】#include #incl
cleopard66
·
2016-02-06 23:00
算法
字典树
hihoCoder
【POJ】3415 Common
Substrings
后缀数组可解。使用单调栈优化。1/*3415*/ 2#include 3#include 4#include 5#include 6#include 7#include 8#include 9#include 10#include 11#include 12#include 13#include 14#include 15#include 16#include 17
Bombe
·
2016-02-03 16:00
【POJ】3415 Common
Substrings
后缀数组可解。使用单调栈优化。1/*3415*/ 2#include 3#include 4#include 5#include 6#include 7#include 8#include 9#include 10#include 11#include 12#include 13#include 14#include 15#include 16#include 17
Bombe
·
2016-02-03 16:00
Substrings
--poj1226(字符串)
DescriptionYouaregivenanumberofcase-sensitivestringsofalphabeticcharacters,findthelargeststringX,suchthateitherX,oritsinversecanbefoundasasubstringofanyofthegivenstrings.InputThefirstlineoftheinputcon
大姑娘龟先生
·
2016-01-27 10:00
上一页
2
3
4
5
6
7
8
9
下一页
按字母分类:
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
其他