Find if string is K-Palindrome or not
Submissions: 1990   Accuracy:

28.13%

  Difficulty: Easy   Marks: 2

Given a string, find out if the string is K-Palindrome or not. A k-palindrome string transforms into a palindrome on removing at most k characters from it.

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 the integers N and K where N denotes the the length of the string.

The second line of each test case contains the string.

Output:

Print 1 if the given string is K-palindrome else print 0. Print the answer for each test case in a new line.


Constraints:

1<= T <=100

1<= N, K <=1000


Example:

Input:

1

8 1

abcdecba

Output:

1

Explanation:

Input : String - abcdecba, k = 1
Output : Yes
String can become palindrome by removing 1 character i.e. either d or e)

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

Contributor: Sujnesh Mishra
Author: Dharmesh


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.