当前位置:网站首页>Nc17 longest palindrome substring
Nc17 longest palindrome substring
2022-07-06 09:40:00 【I'm not Xiao Haiwa~~~~】
describe 
Example 1
Input :
"ababc"
Return value :
3
explain :
The longest palindrome substring is "aba" And "bab", The length is 3
Example 2
Input :
"abbba"
Return value :
5
Example 3
Input :
"b"
Return value :1
Code-( Time unresolved )
bool isHuiwen(string str)
{
for(int i=0;i<str.size()/2;i++)
{
if(str[i]!=str[str.size()-1-i])
return false;
}
return true;
}
int getLongestPalindrome(string A) {
// write code here
int max_len=0;
for(int i=0;i<A.size();i++)
{
int len=1;
for(int j=i;j<A.size();j++)
{
string temp=A.substr(i,len++);
if(isHuiwen(temp)&& temp.size()>max_len)
max_len=temp.size();
}
}
return max_len;
}
边栏推荐
- Appears when importing MySQL
- 基于B/S的网上零食销售系统的设计与实现(附:源码 论文 Sql文件)
- Redis' bitmap
- QML type: locale, date
- Minio distributed file storage cluster for full stack development
- Mapreduce实例(九):Reduce端join
- Research and implementation of hospital management inpatient system based on b/s (attached: source code paper SQL file)
- Compilation of libwebsocket
- 软件负载均衡和硬件负载均衡的选择
- Redis之主从复制
猜你喜欢

Interview shock 62: what are the precautions for group by?

一大波开源小抄来袭

Improved deep embedded clustering with local structure preservation (Idec)

QML control type: Popup

Redis之发布订阅

IDS cache preheating, avalanche, penetration

Servlet learning diary 7 -- servlet forwarding and redirection

Publish and subscribe to redis

O & M, let go of monitoring - let go of yourself

听哥一句劝,按这套嵌入式的课程内容和课程体系去学习
随机推荐
Global and Chinese markets for small seed seeders 2022-2028: Research Report on technology, participants, trends, market size and share
Redis之发布订阅
Scoped in webrtc_ refptr
One article read, DDD landing database design practice
为什么要数据分层
Global and Chinese market of electronic tubes 2022-2028: Research Report on technology, participants, trends, market size and share
YARN组织架构
Why data Tiering
[deep learning] semantic segmentation - source code summary
June brush question 01 - array
Sentinel mode of redis
Reids之删除策略
CAP理论
QML control type: menu
Global and Chinese market of capacitive displacement sensors 2022-2028: Research Report on technology, participants, trends, market size and share
Webrtc blog reference:
MapReduce instance (x): chainmapreduce
【深度学习】语义分割:论文阅读:(CVPR 2022) MPViT(CNN+Transformer):用于密集预测的多路径视觉Transformer
有软件负载均衡,也有硬件负载均衡,选择哪个?
Global and Chinese market of bank smart cards 2022-2028: Research Report on technology, participants, trends, market size and share