Find out the longest palindromic subsequence from a string
Given a string you have to find out the longest palindromic subsequence from the given string.
Input:
T Test case
T no of input string will be given to you.
E.g.
3
bghaufahgt
souabbuos
sahajkhahas
Constrain
1≤ length (string) ≤100
Output:
Print the longest palindromic subsequence from that string
Example
T=3
Input:
bghaufahgt
Output:
ghafahg
Input:
souabbuos
Output:
soubbuos
Input:
sahajkhahas
Output:
sahajahas
To find out the characters in the palindrome we will follow this approach:
C++ Implementation:
Output