题目描述
Given string s and an integer, you have to transform s into a palindrome. In order to achieve that you have to perform exactly k insertion of characters(you cannot perform anymore or less number of insertions). The task is to check if the string can be converted to a palindrome by making exactly k insertions.
Example 1:
Input: s = "abac", K = 2
Output: 1
Explanation: "abac" can be transformed to
"cabbac" (which is palindrome) adding
two characters c and b.
Example 2:
Input: s = "abcde", K = 3
Output: 0
Explanation: "abcde" cannot be transformed
to palindrome using 3 insertions.
Your Task:
You don't need to read input or print anything. Complete the function isPossiblePalindrome() which takes s and K as input parameters and returns a boolean value
Expected Time Complexity: O(|s|^{2})
Expected Auxiliary Space: O(|s|^{2})
Constraints:
1 ≤ |s| ≤ 103
s contains lower case English alphabets
输入格式
见题面
输出格式
见题面