Class Solution
java.lang.Object
g2601_2700.s2696_minimum_string_length_after_removing_substrings.Solution
2696 - Minimum String Length After Removing Substrings.<p>Easy</p>
<p>You are given a string <code>s</code> consisting only of <strong>uppercase</strong> English letters.</p>
<p>You can apply some operations to this string where, in one operation, you can remove <strong>any</strong> occurrence of one of the substrings <code>"AB"</code> or <code>"CD"</code> from <code>s</code>.</p>
<p>Return <em>the <strong>minimum</strong> possible length of the resulting string that you can obtain</em>.</p>
<p><strong>Note</strong> that the string concatenates after removing the substring and could produce new <code>"AB"</code> or <code>"CD"</code> substrings.</p>
<p><strong>Example 1:</strong></p>
<p><strong>Input:</strong> s = “ABFCACDB”</p>
<p><strong>Output:</strong> 2</p>
<p><strong>Explanation:</strong> We can do the following operations:</p>
<ul>
<li>Remove the substring “<ins>AB</ins>FCACDB”, so s = “FCACDB”.</li>
<li>Remove the substring “FCA<ins>CD</ins>B”, so s = “FCAB”.</li>
<li>Remove the substring “FC<ins>AB</ins>”, so s = “FC”.</li>
</ul>
<p>So the resulting length of the string is 2.</p>
<p>It can be shown that it is the minimum length that we can obtain.</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> s = “ACBBD”</p>
<p><strong>Output:</strong> 5</p>
<p><strong>Explanation:</strong> We cannot do any operations on the string so the length remains the same.</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 <= s.length <= 100</code></li>
<li><code>s</code> consists only of uppercase English letters.</li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
minLength
-