Class Solution
java.lang.Object
g1301_1400.s1332_remove_palindromic_subsequences.Solution
1332 - Remove Palindromic Subsequences.<p>Easy</p>
<p>You are given a string <code>s</code> consisting <strong>only</strong> of letters <code>'a'</code> and <code>'b'</code>. In a single step you can remove one <strong>palindromic subsequence</strong> from <code>s</code>.</p>
<p>Return <em>the <strong>minimum</strong> number of steps to make the given string empty</em>.</p>
<p>A string is a <strong>subsequence</strong> of a given string if it is generated by deleting some characters of a given string without changing its order. Note that a subsequence does <strong>not</strong> necessarily need to be contiguous.</p>
<p>A string is called <strong>palindrome</strong> if is one that reads the same backward as well as forward.</p>
<p><strong>Example 1:</strong></p>
<p><strong>Input:</strong> s = “ababa”</p>
<p><strong>Output:</strong> 1</p>
<p><strong>Explanation:</strong> s is already a palindrome, so its entirety can be removed in a single step.</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> s = “abb”</p>
<p><strong>Output:</strong> 2</p>
<p><strong>Explanation:</strong> “abb” -> “bb” -> "". Remove palindromic subsequence “a” then “bb”.</p>
<p><strong>Example 3:</strong></p>
<p><strong>Input:</strong> s = “baabb”</p>
<p><strong>Output:</strong> 2</p>
<p><strong>Explanation:</strong> “baabb” -> “b” -> "". Remove palindromic subsequence “baab” then “b”.</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 <= s.length <= 1000</code></li>
<li><code>s[i]</code> is either <code>'a'</code> or <code>'b'</code>.</li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
removePalindromeSub
-