Problem Statement :
Given a string, find out if the string is K-Palindrome or not.
Note:-
A K-palindrome string transforms into a palindrome on removing at most k characters from it.
Input Format:
The input contains two lines.
The first line has string S.
The second line has the value ‘k’.
Output Format:
The output contains one line either “YES” or “NO” depending on whether the given string ‘S’ is a K palindrome or not.
Given:
abcdeca 2
Output:
YES
Explanation of given Test Cases :
Here we notice that if we remove 'b' and 'd' from the given string, the remaining string is a palindrome.
Approach:
The idea is to find the longest palindromic subsequence of the given string. If the difference between the longest palindromic subsequence and the original string is less than equal to k, then the string is k-palindrome else it is not k-palindrome.