Skip to main content

1332. Remove Palindromic Subsequences

https://leetcode.com/problems/remove-palindromic-subsequences/

Python

  • 因為Subsequence不一定要在原始s內連續,所以其實只可能有三種答案:0, 1, 2
  • 題目限制len(s)最小為1,所以只可能為1或2
class Solution:
def removePalindromeSub(self, s: str) -> int:
if s == s[::-1]:
return 1
return 2