Remove Palindromic Subsequences
To solve this problem, we need to make observations about how the operations can be made. Since the problem allows us to remove a palindromic subsequence, not substring, this means we are allowed to remove non-continuous sequences of characters.
Given the string s, if it is a palindrome itself, we can remove the entire string in one operation. Otherwise, we can always complete the operation in two steps: remove all ‘a’s, then remove all ‘b’s, or vice versa. Both ‘a’ and ‘b’ are palindromic subsequences.
|
|