We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
For every index in the first string find longest palindrome that starts at this index and longest common substring that ends at this index. Repeat this logic for the second string. Of course you need to reverse one of them in both steps. Remember that there can be multiple answers with the same length.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Build a Palindrome
You are viewing a single comment's thread. Return to all comments →
In order to solve this use 2 structures: 1) Palindromic Tree 2) Suffix Tree
For every index in the first string find longest palindrome that starts at this index and longest common substring that ends at this index. Repeat this logic for the second string. Of course you need to reverse one of them in both steps. Remember that there can be multiple answers with the same length.