BETA

Difficulty Level:

Easy

Total Submissions: 233 Accuracy:

28.33%

Minimum steps to delete a string
     

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

Set Default Code

					   
It is recommended to 'Compile & Test' your code before clicking 'Submit'!

Compilation/Execution Result:

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