javacoder1's blog

By javacoder1, history, 8 years ago, In English

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.

  • Vote: I like it
  • +4
  • Vote: I do not like it

»
8 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Ok someone who participated in contest, Please provide their submission because the submissions are not visible.

»
8 years ago, # |
Rev. 4   Vote: I like it +4 Vote: I do not like it

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.