function longestPalindrome(s: string): string {
function expandAroundCenter(left: number, right: number): string {
while (left >= 0 && right < s.length && s[left] === s[right]) {
left--;
right++;
}
return s.substring(left + 1, right);
}
let longest: string = '';
for (let i = 0; i < s.length; i++) {
const oddPalindrome: string = expandAroundCenter(i, i);
if (oddPalindrome.length > longest.length) {
longest = oddPalindrome;
}
const evenPalindrome: string = expandAroundCenter(i, i + 1);
if (evenPalindrome.length > longest.length) {
longest = evenPalindrome;
}
}
return longest;
}