Error
|
|
---|---|
@Ibrahim Nash | 5761 |
@blackshadows | 5715 |
@akhayrutdinov | 5111 |
@mb1973 | 4989 |
@Quandray | 4944 |
@saiujwal13083 | 4506 |
@sanjay05 | 3762 |
@marius_valentin_dragoi | 3516 |
@sushant_a | 3459 |
@verma_ji | 3341 |
@KshamaGupta | 3318 |
Complete Leaderboard | |
|
|
@aroranayan999 | 1115 |
@bt8816103042 | 739 |
@thealchemist627 | 456 |
@dalwainazism125 | 453 |
@akashkale117 | 453 |
@shivanandp12345678910 | 453 |
@SherlockHolmes3 | 447 |
@codeantik | 446 |
@SHOAIBVIJAPURE | 430 |
@shalinibhataniya1097 | 408 |
@ShamaKhan1 | 392 |
Complete Leaderboard |
Given a string 'str' of size ‘n’. The task is to remove or delete minimum number of characters from the string so that the resultant string is palindrome.
Note: The order of characters should be maintained.
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 string str.
The second line of each test case contains the string str.
Output:
Print the minimum number of characters to be deleted to make the string a palindrome for each testcase in a new line.
Constraints:
1<= T <=100
1<= N <= 1000
Example:
Input:
1
7
aebcbda
Output:
2
We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?
Yes