class Solution { longestPalindrome(s: string): string { let res: string = ""; let temp: string = ""; for(let i: number = 0; i < s.length; i++){ for(let j: number = i; j < s.length; j++){ temp += s[j]; let tem: string = temp; tem = tem.split('').reverse().join(''); if(temp === tem) res = res.length > temp.length ? res : temp; } temp = ""; } return res; }

class Solution public string longestPalindromestring s string res=temp=; forint i=0;issize;i++ forint j=i;jssize;j++ temp+=sj; string tem=tem

原文地址: https://www.cveoy.top/t/topic/ikQT 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录