


If the string is ‘AZBCDCBA’, the answer will be YES as we can delete the character ‘Z’ and the remaining string is a palindrome.
The first line of the input contains an integer, 'T,’ denoting the number of test cases.
The first line of each test case has a single integer ‘N’ denoting the length of string ‘S’.
The second line of each test case contains the string ‘S’.
For each test case, print ‘YES’ or ‘NO’ as is it possible to make the string palindrome by deleting at most one character.
You do not need to print anything. It has already been taken care of. Just implement the given function.
1 <= T <= 10
1 <= N <= 10^5.
Time limit: 1 sec
In this approach, we will first define a function IS_PALINDROME(‘S’, i,j), which returns whether the substring from i to j is palindrome or not. Now, we will take two pointers, i and j, and iterate the string using these pointers, one from the front and another from the back, when we find a condition that S[i] is not equal to S[j]. We have two choices:
Delete ith character. If substring from i+1 to j is a palindrome, the answer is true.
Delete jth character. If substring from i to j-1 is a palindrome, the answer is true.
If neither is true, we cant make this string palindrome. So return false.
If we never encounter the above condition, it means that our string is already palindrome. So, return simply true.