If the string is already a palindromic string, return 1.
If the string is not palindromic, then there must be 2 letters in the string
and we could not solve this problem in less than 2 steps. But we could solve
it in exactly 2 steps by first remove all a s and then all b s.
Solution
class Solution:
def removePalindromeSub(self, s: str) -> int:
if not s:
return 0
if s == s[::-1]:
return 1
return 2