Skip to content

Commit a4b26d4

Browse files
committed
Create README - LeetHub
1 parent 870f113 commit a4b26d4

File tree

1 file changed

+40
-0
lines changed
  • 2027-minimum-moves-to-convert-string

1 file changed

+40
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<h2><a href="https://leetcode.com/problems/minimum-moves-to-convert-string">2027. Minimum Moves to Convert String</a></h2><h3>Easy</h3><hr><p>You are given a string <code>s</code> consisting of <code>n</code> characters which are either <code>&#39;X&#39;</code> or <code>&#39;O&#39;</code>.</p>
2+
3+
<p>A <strong>move</strong> is defined as selecting <strong>three</strong> <strong>consecutive characters</strong> of <code>s</code> and converting them to <code>&#39;O&#39;</code>. Note that if a move is applied to the character <code>&#39;O&#39;</code>, it will stay the <strong>same</strong>.</p>
4+
5+
<p>Return <em>the <strong>minimum</strong> number of moves required so that all the characters of </em><code>s</code><em> are converted to </em><code>&#39;O&#39;</code>.</p>
6+
7+
<p>&nbsp;</p>
8+
<p><strong class="example">Example 1:</strong></p>
9+
10+
<pre>
11+
<strong>Input:</strong> s = &quot;XXX&quot;
12+
<strong>Output:</strong> 1
13+
<strong>Explanation:</strong> <u>XXX</u> -&gt; OOO
14+
We select all the 3 characters and convert them in one move.
15+
</pre>
16+
17+
<p><strong class="example">Example 2:</strong></p>
18+
19+
<pre>
20+
<strong>Input:</strong> s = &quot;XXOX&quot;
21+
<strong>Output:</strong> 2
22+
<strong>Explanation:</strong> <u>XXO</u>X -&gt; O<u>OOX</u> -&gt; OOOO
23+
We select the first 3 characters in the first move, and convert them to <code>&#39;O&#39;</code>.
24+
Then we select the last 3 characters and convert them so that the final string contains all <code>&#39;O&#39;</code>s.</pre>
25+
26+
<p><strong class="example">Example 3:</strong></p>
27+
28+
<pre>
29+
<strong>Input:</strong> s = &quot;OOOO&quot;
30+
<strong>Output:</strong> 0
31+
<strong>Explanation:</strong> There are no <code>&#39;X&#39;s</code> in <code>s</code> to convert.
32+
</pre>
33+
34+
<p>&nbsp;</p>
35+
<p><strong>Constraints:</strong></p>
36+
37+
<ul>
38+
<li><code>3 &lt;= s.length &lt;= 1000</code></li>
39+
<li><code>s[i]</code> is either <code>&#39;X&#39;</code> or <code>&#39;O&#39;</code>.</li>
40+
</ul>

0 commit comments

Comments
 (0)