Solve longest palindromic substring for a string problem in leetcode.