1

I know that Manacher's algorithm can be used to find the longest palindromic substring of a string in linear time. But I want to find the longest palindromic substring after swapping any two indices once.

If I run a for loop twice in $O(n^2)$ to find all possible swaps and find the max of all formed strings I get the ans but in $O(n^3)$. Is there a better way like $O(n)$?

Sharingan
  • 11
  • 3

0 Answers0