https://leetcode.com/problems/valid-palindrome-iii/description/
This is a counterpart question of 516. Longest Palindromic Subsequence.
Given the lenghth of the string is l
, if we could find the length of Longest Palindromic Subsequence p
, it means we at least need to delete l - p
chars to get a palindrom.
Then we only need to check l - p <= k
to answer if a string can be transformed into a palindrome by removing at most k characters from it.