Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Longest Palindromic Sub-sequence #235

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

mitali004
Copy link
Contributor

ISSUE NUMBER

117

SHORT DESCRIPTION

Added the code for longest palindromic subsequence along with a readme.md for it.


### Filling of the matrix
Every single charecter contributes to a palindromic string of length 1 starting and ending at itself, therefore we fill the diagonal of the
matrix with 1 for every [i][i] entry. <br/><br/>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make like this [i][i]

For every other entry:<br/>
If last and first characters of str are same, then mat[i][j] = mat[i+1][j-1] + 2, as it considers [2(for the first and the last chaar)] +
[longest palindromic subsequence between these 2 chars].<br/>
Else mat[i][j] = max(mat[i][j-1], mat[i+1][j]).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similarly add ` before and after

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants