1332. Remove Palindromic Subsequences ¶ Time: $O(n)$ Space: $O(1)$ C++JavaPython 1 2 3 4 5 6class Solution { public: int removePalindromeSub(string s) { return equal(s.begin(), s.end(), s.rbegin()) ? 1 : 2; } }; 1 2 3 4 5class Solution { public int removePalindromeSub(String s) { return s.equals(new StringBuilder(s).reverse().toString()) ? 1 : 2; } } 1 2 3class Solution: def removePalindromeSub(self, s: str) -> int: return 1 if s == s[::-1] else 2