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

Feature: Longest palindromic subsequence in cpp #3878

Open
cyano004 opened this issue Oct 2, 2022 · 10 comments
Open

Feature: Longest palindromic subsequence in cpp #3878

cyano004 opened this issue Oct 2, 2022 · 10 comments

Comments

@cyano004
Copy link

cyano004 commented Oct 2, 2022

I would liike to add unique solution to the longest paliindromic subsequence in cpp

@heyhimansh
Copy link

hey i would like to add cpp solution for this

@abhaysingla05
Copy link

Assign me this !!

@vkaash-sharma
Copy link

i can do this by using another approach please assign to me

@Sakshiwalode28
Copy link

I would like to work on this issue please assign it to me.

@AdityaSai2004
Copy link

@keshavsingh4522 I would like to share my solution for this. Would be great if I can get assigned to it.

@Riya-2211
Copy link

#include<bits/stdc++.h>
using namespace std;

// A utility function to get max of two integers
int max (int x, int y) { return (x > y)? x : y; }

// Returns the length of the longest palindromic subsequence in seq
int lps(char *seq, int i, int j)
{
// Base Case 1: If there is only 1 character
if (i == j)
return 1;

// Base Case 2: If there are only 2
// characters and both are same
if (seq[i] == seq[j] && i + 1 == j)
return 2;

// If the first and last characters match
if (seq[i] == seq[j])
return lps (seq, i+1, j-1) + 2;

// If the first and last characters do not match
return max( lps(seq, i, j-1), lps(seq, i+1, j) );
}

/* Driver program to test above functions */
int main()
{
char seq[] = "GEEKSFORGEEKS";
int n = strlen(seq);
cout << "The length of the LPS is "
<< lps(seq, 0, n-1);
return 0;
}

@ragnarok-02
Copy link

I would like to work on this issue, please assign this to me.

@ghost
Copy link

ghost commented Oct 11, 2022

assign me this

@kanikarajpal
Copy link

Can you please assign this to me?

@prabhat108
Copy link

HEY PLEASE ASSIGN IT TO ME

ujjwalshivhare added a commit to ujjwalshivhare/hacktoberfest2021 that referenced this issue Oct 3, 2023
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

No branches or pull requests

10 participants