A palindrome is a string which is the same when read forwards and backwards. For example "racecar" is a palindrome, but "Racecar" is not. A substring is a contiguous set of characters in a larger string. Your task is to write a program or method which takes a string or character array as input and outputs the length of the longest substring of that string which is a palindrome.
Examples
Input
banana
Ouput
5
This is because "anana" is a 5 character substring of "banana"
Input
abracadabra
Output
3
This is because both "aca" and "ada" are 3 characters.
Input
True
Output
1
This string has no palindromes that are more than 1 character.
If the input is the empty string the output must be 0.
This is code-golf so the shortest submission in any language wins.
Note: There have been slight variations of this question in the past, which have all had wording issues or been asking a variation of this question. You can see these:
Find the Longest Palindrome in a String by Removing Characters
Longest reverse palindromic DNA substring
How do I find the longest palindrome in a string?
Finding "sub-palindromes". - The purpose of this challenge is to print all palindromic substring, rather than the length of the longest. As such many of the answers to this question do not have close analogues.
.
,+
,*
etc) because just using them as is will cause errors. There is also the issue of spaces and newlines and how they are handled in I/O. Languages likeC
might worry about\0
etc. \$\endgroup\$