const str2 = '1111waabbibiiomomomomomo'
const str1 = '11111111111111111111111'
const str = 'abcbcajkljljljlnninino'
/**
* 最长回文子串
*/
function longestSubStr(str) {
let i = 0;j = str.length -1;
str = str.split('')
let result = []
while(i <j) {
if(str[i] === str[j]) {
i ++ ,
j --
result.push(str[i])
} else {
i ++
}
}
if(result.length === 1) {
return null
}
return [...result,...result].join('');
}
const res = longestSubStr(str2)
console.log(res);
leetcode5-最長の部分文字列を見つける
おすすめ
転載: blog.csdn.net/weixin_40944062/article/details/113104831
おすすめ
ランキング