Recently I got to know about this O(n) solution for longest palindromic substring and am stunned by the working of the algorithm. How could an algorithm work better than a grid DP solution?! Would be nice if anyone could break down the algorithm for me. Also looking forward to know about more such daring algorithms that can beat the crap out of the traditional dynamic programming solutions. Thank you.
Dijkstra's Shortest Path Algorithm (Greedy) | Time Complexity: O(ELogV + VLogV)
I never learned Manacher's algorithm. I always used hashing. Hash the string forwards and backwards and then compare.
can you please share your approach/code using the hashing?
Hash the string forward, so like abcd and then hash backwards on dcba.
Using suffix arrays, Longest Common Substring for 2 strings can be solved in O(nlogn) instead of O(n2) DP, and also it performs drastically better for more number of strings.