当前位置:网站首页>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;
}
边栏推荐
- Master slave replication of redis
- QML control type: menu
- Oom happened. Do you know the reason and how to solve it?
- Segmentation sémantique de l'apprentissage profond - résumé du code source
- Lua script of redis
- MapReduce instance (IX): reduce end join
- Mapreduce实例(六):倒排索引
- 【深度學習】語義分割-源代碼匯總
- 为什么大学单片机课上51+汇编,为什么不直接来STM32
- 五月刷题02——字符串
猜你喜欢
随机推荐
Redis分布式锁实现Redisson 15问
[deep learning] semantic segmentation: paper reading: (2021-12) mask2former
[deep learning] semantic segmentation - source code summary
MapReduce instance (x): chainmapreduce
In order to get an offer, "I believe that hard work will make great achievements
数据建模有哪些模型
Kratos ares microservice framework (III)
MapReduce instance (VI): inverted index
Interview shock 62: what are the precautions for group by?
Global and Chinese market for annunciator panels 2022-2028: Research Report on technology, participants, trends, market size and share
Redis cluster
QML control type: menu
YARN组织架构
发生OOM了,你知道是什么原因吗,又该怎么解决呢?
Global and Chinese markets of SERS substrates 2022-2028: Research Report on technology, participants, trends, market size and share
Une grande vague d'attaques à la source ouverte
六月刷题01——数组
Global and Chinese market of electric pruners 2022-2028: Research Report on technology, participants, trends, market size and share
DCDC power ripple test
Solve the problem of too many small files


![《ASP.NET Core 6框架揭秘》样章发布[200页/5章]](/img/4f/5688c391dd19129d912a3557732047.jpg)




