Skip to content

Commit bf25153

Browse files
committed
Create README - LeetHub
1 parent 3d3ba0e commit bf25153

File tree

1 file changed

+32
-0
lines changed
  • 1653-minimum-deletions-to-make-string-balanced

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<h2><a href="https://leetcode.com/problems/minimum-deletions-to-make-string-balanced">1653. Minimum Deletions to Make String Balanced</a></h2><h3>Medium</h3><hr><p>You are given a string <code>s</code> consisting only of characters <code>&#39;a&#39;</code> and <code>&#39;b&#39;</code>​​​​.</p>
2+
3+
<p>You can delete any number of characters in <code>s</code> to make <code>s</code> <strong>balanced</strong>. <code>s</code> is <strong>balanced</strong> if there is no pair of indices <code>(i,j)</code> such that <code>i &lt; j</code> and <code>s[i] = &#39;b&#39;</code> and <code>s[j]= &#39;a&#39;</code>.</p>
4+
5+
<p>Return <em>the <strong>minimum</strong> number of deletions needed to make </em><code>s</code><em> <strong>balanced</strong></em>.</p>
6+
7+
<p>&nbsp;</p>
8+
<p><strong class="example">Example 1:</strong></p>
9+
10+
<pre>
11+
<strong>Input:</strong> s = &quot;aababbab&quot;
12+
<strong>Output:</strong> 2
13+
<strong>Explanation:</strong> You can either:
14+
Delete the characters at 0-indexed positions 2 and 6 (&quot;aa<u>b</u>abb<u>a</u>b&quot; -&gt; &quot;aaabbb&quot;), or
15+
Delete the characters at 0-indexed positions 3 and 6 (&quot;aab<u>a</u>bb<u>a</u>b&quot; -&gt; &quot;aabbbb&quot;).
16+
</pre>
17+
18+
<p><strong class="example">Example 2:</strong></p>
19+
20+
<pre>
21+
<strong>Input:</strong> s = &quot;bbaaaaabb&quot;
22+
<strong>Output:</strong> 2
23+
<strong>Explanation:</strong> The only solution is to delete the first two characters.
24+
</pre>
25+
26+
<p>&nbsp;</p>
27+
<p><strong>Constraints:</strong></p>
28+
29+
<ul>
30+
<li><code>1 &lt;= s.length &lt;= 10<sup>5</sup></code></li>
31+
<li><code>s[i]</code> is&nbsp;<code>&#39;a&#39;</code> or <code>&#39;b&#39;</code>​​.</li>
32+
</ul>

0 commit comments

Comments
 (0)