1 year ago
#357220
Esteban Montelongo
Longest Common Palindromic Subtring
Does anyone know how to do this algorithm top-down with memoization? My first intuition was to reduce this problem to Longest Common Substring, but check each substring and see if it's a palindrome. I just can't figure out how to do this recursively. Can someone please help me out?
Problem Statement #
Given two strings ‘s1’ and ‘s2’, find the length of the longest palindromic
substring which is common in both the strings.
Example 1:
Input: s1 = "fbdbaccf"
s2 = "tbdbaccf"
Output: 3
Explanation: The longest common substring is "bdb".
Example 2:
Input: s1 = "abcdefghimississippi"
s2 = "abcdefghiississi"
Output: 7
Explanation: The longest common substring is "ississi".
algorithm
substring
palindrome
memoization
0 Answers
Your Answer