Each character (and each pair of adjacent characters) is treated as a potential center of a palindrome. Expand outwards while the characters match. Keep track of the longest palindrome found.
// this is one of the most optimised solution where time Complexity = O(n^2) and space complexity = O(1). This is optimised over DP . This is basically based on the concept that palindrome mirrors ...