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
5d

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...
Top Microsoft Corporation Software Developer Intern interview questions & answers
Popular interview questions of Software Developer Intern
Top HR questions asked in Microsoft Corporation Software Developer Intern
>
Microsoft Corporation Software Developer Intern Interview Questions
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app