Longest Palindromic Subsequence Problem Statement
Ninja receives a PS5 from Santa, locked in a safe with a password. The password is the length of the longest palindromic subsequence in the given string SECRETCODE
. Can you determine this password to help Ninja open the safe?
Input:
The first line contains an integer 'T', indicating the number of test cases. Each test case has two lines: the first line is an integer 'N' representing the length of the string 'SECRETCODE', and the second line contains the string 'SECRETCODE'.
Output:
For each test case, output a single integer on a new line, which is the length of the longest palindromic subsequence in 'SECRETCODE'.
Example:
Input:
2
7
CACBDBA
3
AAA
Output:
4
3
Constraints:
- 1 <= T <= 10
- 1 <= N <= 103
Note: 'SECRETCODE' consists only of English uppercase letters.

AnswerBot
4mo
The task is to find the length of the longest palindromic subsequence in a given string.
Iterate through the string and create a 2D array to store the lengths of palindromic subsequences.
Use dynamic pr...read more
Help your peers!
Add answer anonymously...
Microsoft Corporation Software Developer Intern interview questions & answers
A Software Developer Intern was asked 7mo agoQ. What were your responsibilities during your internship?
A Software Developer Intern was asked 7mo agoQ. What is the difference between polymorphism and inheritance?
A Software Developer Intern was asked 9mo agoQ. Given a string, reverse the order of characters using standard data structures a...read more
Popular interview questions of Software Developer Intern
A Software Developer Intern was asked 6mo agoQ1. What were your responsibilities during your internship?
A Software Developer Intern was asked 6mo agoQ2. What is the difference between polymorphism and inheritance?
A Software Developer Intern was asked 8mo agoQ3. Given a string, reverse the order of characters using standard data structures a...read more
>
Microsoft Corporation Software Developer Intern Interview Questions
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

