Skip to content

Commit efd5f5c

Browse files
committed
Create README - LeetHub
1 parent 27cda25 commit efd5f5c

File tree

1 file changed

+50
-0
lines changed
  • 2914-minimum-number-of-changes-to-make-binary-string-beautiful

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-number-of-changes-to-make-binary-string-beautiful/">2914. Minimum Number of Changes to Make Binary String Beautiful</a></h2><h3>Medium</h3><hr><p>You are given a <strong>0-indexed</strong> binary string <code>s</code> having an even length.</p>
2+
3+
<p>A string is <strong>beautiful</strong> if it&#39;s possible to partition it into one or more substrings such that:</p>
4+
5+
<ul>
6+
<li>Each substring has an <strong>even length</strong>.</li>
7+
<li>Each substring contains <strong>only</strong> <code>1</code>&#39;s or <strong>only</strong> <code>0</code>&#39;s.</li>
8+
</ul>
9+
10+
<p>You can change any character in <code>s</code> to <code>0</code> or <code>1</code>.</p>
11+
12+
<p>Return <em>the <strong>minimum</strong> number of changes required to make the string </em><code>s</code> <em>beautiful</em>.</p>
13+
14+
<p>&nbsp;</p>
15+
<p><strong class="example">Example 1:</strong></p>
16+
17+
<pre>
18+
<strong>Input:</strong> s = &quot;1001&quot;
19+
<strong>Output:</strong> 2
20+
<strong>Explanation:</strong> We change s[1] to 1 and s[3] to 0 to get string &quot;1100&quot;.
21+
It can be seen that the string &quot;1100&quot; is beautiful because we can partition it into &quot;11|00&quot;.
22+
It can be proven that 2 is the minimum number of changes needed to make the string beautiful.
23+
</pre>
24+
25+
<p><strong class="example">Example 2:</strong></p>
26+
27+
<pre>
28+
<strong>Input:</strong> s = &quot;10&quot;
29+
<strong>Output:</strong> 1
30+
<strong>Explanation:</strong> We change s[1] to 1 to get string &quot;11&quot;.
31+
It can be seen that the string &quot;11&quot; is beautiful because we can partition it into &quot;11&quot;.
32+
It can be proven that 1 is the minimum number of changes needed to make the string beautiful.
33+
</pre>
34+
35+
<p><strong class="example">Example 3:</strong></p>
36+
37+
<pre>
38+
<strong>Input:</strong> s = &quot;0000&quot;
39+
<strong>Output:</strong> 0
40+
<strong>Explanation:</strong> We don&#39;t need to make any changes as the string &quot;0000&quot; is beautiful already.
41+
</pre>
42+
43+
<p>&nbsp;</p>
44+
<p><strong>Constraints:</strong></p>
45+
46+
<ul>
47+
<li><code>2 &lt;= s.length &lt;= 10<sup>5</sup></code></li>
48+
<li><code>s</code> has an even length.</li>
49+
<li><code>s[i]</code> is either <code>&#39;0&#39;</code> or <code>&#39;1&#39;</code>.</li>
50+
</ul>

0 commit comments

Comments
 (0)