Hacked String

Computer Science Level pending

Lew sends Chris a string and asks for its longest palindromic substring. During the process, someone hacked the file and changed one character.

Chris wonders, what could be the length of the longest palindromic substring in the initial string?

Here is the string after the modification.

Sample Input

dabcaaef

Sample Output

5

Explanation

If we change the fifth character to b then the longest palindromic substring is abcba . There will be no palindromic substring longer than this after any modification of one character.

Details and Assumptions

  • The length of the string is 1000.
  • The file only contains lowercase alphabetical letter.


The answer is 100.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

0 solutions

No explanations have been posted yet. Check back later!

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...