Minimum steps to delete a string
Submissions: 817   Accuracy:

26.55%

  Difficulty: Easy   Marks: 2

Given a string containing characters as integers only. We need to delete all character of this string in a minimum number of steps where in one step we can delete the substring which is a palindrome. After deleting a substring remaining parts are concatenated.

Input:

The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. The first line of each test case contains an integer N denoting the length of the string.

The second line of each test case contains the string consisting of only integer characters.


Output:

Count the minimum number of steps to delete the whole string and output the answer in a new line.


Constraints:

1<= T <=100

1<= N <=1000


Example:

Input:

1

7

2553432

Output:

2

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Sujnesh Mishra
Author: sujnesh


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.