How to find the Longest Palindrome String in Java ?
- A palindrome is a word, phrase, number, or other sequence of characters which reads the same backward as forward, example as madam.
- Write a java program to find the longest palindrome present in a given string.
Longest Palindrome in a String Using Java
- The string can be of odd or even length and hence the findLongestPalindromeWithSpecifiedParameter() is called twice for each string.
- In the method, findLongestPalindromeWithSpecifiedParameter() left will decrement and move towards the start of the string until it reaches start and then right will increment and move towards the end of the string until it reaches the end.
- And any left and right reach destination (i.e. start and end respectively)at any point then the method will return.