I am unable to solve the question https://www.hackerrank.com/contests/codeagon/challenges/jesse-and-two-strings-
The editorial is clear to me upto the point where i encounter the following statement After finding the LPS for the both the strings, we traverse through L(i,i)=Length of LPS,∀i=0...N−1 and see what all the middle characters can both the LPS's have. Can someone explain me this? Thanks.
Ok someone who participated in contest, Please provide their submission because the submissions are not visible.
The solutions are public now. :)
http://ideone.com/C54QLn if len1 and len2 are odd then:-
after finding Lps Just traverse through the strings and mark the characters that can be used as a centre in odd length palindrome. if both strings have a common character that can be used as a centre in both then ans is len1+len2 else len1+len2-1. for more details refer code.
else:- the ans is len1+len2 always.