Longest Palindromic Subsequence Problem Statement
Given a string A
consisting of lowercase English letters, determine the length of the longest palindromic subsequence within A
.
Explanation:
- A subsequence is derived from a string by deleting some or no characters without changing the order of the remaining characters.
- A string is a palindrome if it reads the same forwards and backwards (e.g., "abba").
Input:
The first line contains an integer ‘T’, indicating the number of test cases. Each test case consists of a single string ‘A’.
Output:
Output a single integer per test case, representing the length of the longest palindromic subsequence in ‘A’.
Example:
Input:
2
bbabcbcab
dcbccbcabbb
Output:
7
7
Constraints:
- 1 <= T <= 10
- 1 <= N <= 102
- Where ‘T’ represents the number of test cases and ‘N’ represents the length of the string.
- Time limit: 1 second.
Note:
No need to print anything; implement the function to obtain the result.

AnswerBot
1y
The task is to find the length of the longest palindromic subsequence in a given string.
A subsequence is a sequence generated from a string after deleting some or no characters of the string without c...read more
Help your peers!
Add answer anonymously...
Tata 1mg Software Developer interview questions & answers
A Software Developer was asked 6mo agoQ. Explain Red Black Tree.
A Software Developer was asked 6mo agoQ. Given a 1-D array, how would you find the local minima?
A Software Developer was asked 11mo agoQ. How would you align two images on a page to have the same width and height?
Popular interview questions of Software Developer
A Software Developer was asked 6mo agoQ1. Explain Red Black Tree.
A Software Developer was asked 11mo agoQ2. How would you align two images on a page to have the same width and height?
A Software Developer was asked Q3. Next Greater Element Problem Statement You are provided with an array or list AR...read more
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

