Skip to content

Commit 2c2dec8

Browse files
committed
Create README - LeetHub
1 parent abc309a commit 2c2dec8

File tree

1 file changed

+38
-0
lines changed
  • 0921-minimum-add-to-make-parentheses-valid

1 file changed

+38
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<h2><a href="https://leetcode.com/problems/minimum-add-to-make-parentheses-valid">921. Minimum Add to Make Parentheses Valid</a></h2><h3>Medium</h3><hr><p>A parentheses string is valid if and only if:</p>
2+
3+
<ul>
4+
<li>It is the empty string,</li>
5+
<li>It can be written as <code>AB</code> (<code>A</code> concatenated with <code>B</code>), where <code>A</code> and <code>B</code> are valid strings, or</li>
6+
<li>It can be written as <code>(A)</code>, where <code>A</code> is a valid string.</li>
7+
</ul>
8+
9+
<p>You are given a parentheses string <code>s</code>. In one move, you can insert a parenthesis at any position of the string.</p>
10+
11+
<ul>
12+
<li>For example, if <code>s = &quot;()))&quot;</code>, you can insert an opening parenthesis to be <code>&quot;(<strong>(</strong>)))&quot;</code> or a closing parenthesis to be <code>&quot;())<strong>)</strong>)&quot;</code>.</li>
13+
</ul>
14+
15+
<p>Return <em>the minimum number of moves required to make </em><code>s</code><em> valid</em>.</p>
16+
17+
<p>&nbsp;</p>
18+
<p><strong class="example">Example 1:</strong></p>
19+
20+
<pre>
21+
<strong>Input:</strong> s = &quot;())&quot;
22+
<strong>Output:</strong> 1
23+
</pre>
24+
25+
<p><strong class="example">Example 2:</strong></p>
26+
27+
<pre>
28+
<strong>Input:</strong> s = &quot;(((&quot;
29+
<strong>Output:</strong> 3
30+
</pre>
31+
32+
<p>&nbsp;</p>
33+
<p><strong>Constraints:</strong></p>
34+
35+
<ul>
36+
<li><code>1 &lt;= s.length &lt;= 1000</code></li>
37+
<li><code>s[i]</code> is either <code>&#39;(&#39;</code> or <code>&#39;)&#39;</code>.</li>
38+
</ul>

0 commit comments

Comments
 (0)