text and an integer budget. You may erase at most budget characters from the string, any characters at any positions; the remaining ones keep their order.
Can you erase characters so that what is left reads the same forwards and backwards? Return True if you can and False otherwise.text='radkar', budget=1 → True
Erasing the "k" leaves the palindrome "radar".
text='lever', budget=1 → False
The longest palindrome that can be kept is "eve", three letters long, so two letters must go while only one may be erased.
text='noon', budget=1 → True
The string is already a palindrome, nothing has to be erased.
text.length ≤ 1000text consists of lowercase English letters onlybudget ≤ text.lengthtext='radkar', budget=1
True
Run checks the first 3 tests in your browser. Submit checks all 105 tests on the server, hidden ones included.