Skip to content

Commit b657a56

Browse files
committed
Create README - LeetHub
1 parent ba890b6 commit b657a56

File tree

1 file changed

+50
-0
lines changed
  • 4090-minimum-string-length-after-balanced-removals

1 file changed

+50
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<h2><a href="https://leetcode.com/problems/minimum-string-length-after-balanced-removals">4090. Minimum String Length After Balanced Removals</a></h2><h3>Medium</h3><hr><p>You are given a string <code>s</code> consisting only of the characters <code>&#39;a&#39;</code> and <code>&#39;b&#39;</code>.</p>
2+
3+
<p>You are allowed to repeatedly remove <strong>any <span data-keyword="substring-nonempty">substring</span></strong> where the number of <code>&#39;a&#39;</code> characters is equal to the number of <code>&#39;b&#39;</code> characters. After each removal, the remaining parts of the string are concatenated together without gaps.</p>
4+
5+
<p>Return an integer denoting the <strong>minimum possible length</strong> of the string after performing any number of such operations.</p>
6+
7+
<p>&nbsp;</p>
8+
<p><strong class="example">Example 1:</strong></p>
9+
10+
<div class="example-block">
11+
<p><strong>Input:</strong> <span class="example-io">s = <code>&quot;aabbab&quot;</code></span></p>
12+
13+
<p><strong>Output:</strong> <span class="example-io">0</span></p>
14+
15+
<p><strong>Explanation:</strong></p>
16+
17+
<p>The substring <code>&quot;aabbab&quot;</code> has three <code>&#39;a&#39;</code> and three <code>&#39;b&#39;</code>. Since their counts are equal, we can remove the entire string directly. The minimum length is 0.</p>
18+
</div>
19+
20+
<p><strong class="example">Example 2:</strong></p>
21+
22+
<div class="example-block">
23+
<p><strong>Input:</strong> <span class="example-io">s = <code>&quot;aaaa&quot;</code></span></p>
24+
25+
<p><strong>Output:</strong> <span class="example-io">4</span></p>
26+
27+
<p><strong>Explanation:</strong></p>
28+
29+
<p>Every substring of <code>&quot;aaaa&quot;</code> contains only <code>&#39;a&#39;</code> characters. No substring can be removed as a result, so the minimum length remains 4.</p>
30+
</div>
31+
32+
<p><strong class="example">Example 3:</strong></p>
33+
34+
<div class="example-block">
35+
<p><strong>Input:</strong> <span class="example-io">s = <code>&quot;aaabb&quot;</code></span></p>
36+
37+
<p><strong>Output:</strong> <span class="example-io">1</span></p>
38+
39+
<p><strong>Explanation:</strong></p>
40+
41+
<p>First, remove the substring <code>&quot;ab&quot;</code>, leaving <code>&quot;aab&quot;</code>. Next, remove the new substring <code>&quot;ab&quot;</code>, leaving <code>&quot;a&quot;</code>. No further removals are possible, so the minimum length is 1.</p>
42+
</div>
43+
44+
<p>&nbsp;</p>
45+
<p><strong>Constraints:</strong></p>
46+
47+
<ul>
48+
<li><code>1 &lt;= s.length &lt;= 10<sup>5</sup></code></li>
49+
<li><code>s[i]</code> is either <code>&#39;a&#39;</code> or <code>&#39;b&#39;</code>.</li>
50+
</ul>

0 commit comments

Comments
 (0)