Problem Explanation
We have to find the length of the longest palindrome substring in the string.
Approach
- We first check if the whole string is a palindrome by checking if it is equal to it’s reverse.
- If Yes, print the length of the whole string.
- Else, We iterate over all the possible substrings and check if they are equal to their reverse and their length is greater than the current found max.
- If Yes, we replace the current found max with the length of the substring.
- Then, we print the max substring length found.