Palindromic Indices Codeforces Solution | Codeforces Problem Solution 2022
You are given a palindromic string of length .
You have to count the number of indices such that the string after removing from still remains a palindrome.
For example, consider = "aba"
- If we remove from , the string becomes "ba" which is not a palindrome.
- If we remove from , the string becomes "aa" which is a palindrome.
- If we remove from , the string becomes "ab" which is not a palindrome.
The input consists of multiple test cases. The first line of the input contains a single integer — the number of test cases. Description of the test cases follows.
The first line of each testcase contains a single integer — the length of string .
The second line of each test case contains a string consisting of lowercase English letters. It is guaranteed that is a palindrome.
It is guaranteed that sum of over all test cases does not exceed .
For each test case, output a single integer — the number of indices such that the string after removing from still remains a palindrome.
No comments:
Post a Comment