how to find longest palindromic subsequence?

This can be solved in O(n^2) using dynamic programming. Basically, the problem is about building the longest palindromic subsequence in x[i…j] using the longest subsequence for x[i+1…j], x[i,…j-1] and x[i+1,…,j-1] (if first and last letters are the same). Firstly, the empty string and a single character string is trivially a palindrome. Notice that for a … Read more

Manacher’s algorithm (algorithm to find longest palindrome substring in linear time)

I agree that the logic isn’t quite right in the explanation of the link. I give some details below. Manacher’s algorithm fills in a table P[i] which contains how far the palindrome centered at i extends. If P[5]=3, then three characters on either side of position five are part of the palindrome. The algorithm takes … Read more

How to check that a string is a palindrome using regular expressions?

The answer to this question is that “it is impossible”. More specifically, the interviewer is wondering if you paid attention in your computational theory class. In your computational theory class you learned about finite state machines. A finite state machine is composed of nodes and edges. Each edge is annotated with a letter from a … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)