K Palindrome
A string is a k-palindrome if it can be transformed into a palindrome by removing any amount of characters from 0 to k. Your task is to determine whether the given string s is a k-palindrome.
Example
For
s = "abrarbra"andk = 1, the output should bekpalindrome(s, k) = true.You can remove one letter,
'r', to obtain the string"abrarba", which is a palindrome.For
s = "adbcdbacdb"andk = 2, the output should bekpalindrome(s, k) = false.
Input/Output
[execution time limit] 3 seconds (java)
[input] string s
A string containing only lowercase English letters.
Guaranteed constraints:
3 ≤ s.length ≤ 100.[input] integer k
Guaranteed constraints:
1 ≤ k ≤ 20.[output] boolean
- Return
trueif it is possible to delete at mostkletters from a stringsin order to make it palindrome. Returnfalseotherwise.
- Return