SarthakKeshari / CPP-Questions-and-Solutions

This repository aims to solve and create new problems from different spheres of coding. A path to help students to get access to solutions and discuss their doubts.
MIT License
45 stars 132 forks source link

Longest Palindromic Subsequence #416

Closed PrakharRathore123 closed 2 years ago

PrakharRathore123 commented 2 years ago

Issue Id you have worked upon -

387

Briefly explain your program logic -

1)If string has only one value then return 1 2)If string has only one value then return 2 3)If string has only first and last character are same then call recursive function. 4)If string has only first and last character are not same then call the recursive function with max function.

Test Cases-

Test 1 ) For the input of string="PRAKHAR" Longest Palindromic Subsequence possible is "RAHAR" so max length is 5

Test 2 ) For the input of string="SARTHAK" Longest Palindromic Subsequence possible is "AHA" so max length is 3

Screenshots(Attach 2 screenshots of your own input and output) -

Attach here LPSA LPSB


Checklist:

Eg - If your code follow the below guidelines. Kindly change [] to [x]

All the conditions should be fulfilled for considering your code for merging -

PrakharRathore123 commented 2 years ago

@SarthakKeshari Kindly acknowledge this.