You are not logged in. Please login at www.codechef.com to post your questions!

×

Longest palindromic substring in the given string?

Can anyone explain how do we find the longest palindromic sub string of in the given string. I know this is the standard DP problem, so please provide the proper DP explanation including overlapping sub-problems and optimal substructure, recursive solution and also what do we need to memorize.

asked 14 Sep '17, 14:53

arpit728's gravatar image

1★arpit728
6831868
accept rate: 10%


Well, if you only want the dp solution, You may refer This article. It explains in detail the basic state, transition and filling up the dp array.

But there are better approach for this problem, like here with same time complexity, but improved space complexity here.

If you want a really faster approach, like for string with length greater than 1000, you would like to have a look at manacher's algorithm, a linear time algorithm for your prob here.

Hope this helps....

Please Upvote if u find this hepful....

link

answered 14 Sep '17, 21:45

taran_1407's gravatar image

6★taran_1407
4.0k31103
accept rate: 22%

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×1,664
×643
×235
×133

question asked: 14 Sep '17, 14:53

question was seen: 942 times

last updated: 14 Sep '17, 21:45