Skip to content

Commit 118c19c

Browse files
author
Shuo
authored
Merge pull request #604 from openset/develop
Add: new
2 parents b7f67a5 + 65eac1d commit 118c19c

File tree

6 files changed

+169
-1
lines changed

6 files changed

+169
-1
lines changed

Diff for: README.md

+4
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ LeetCode Problems' Solutions
5454

5555
| # | Title | Solution | Difficulty |
5656
| :-: | - | - | :-: |
57+
| <span id="1111">1111</span> | [Maximum Nesting Depth of Two Valid Parentheses Strings](https://leetcode.com/problems/maximum-nesting-depth-of-two-valid-parentheses-strings "有效括号的嵌套深度") | [Go](https://github.com/openset/leetcode/tree/master/problems/maximum-nesting-depth-of-two-valid-parentheses-strings) | Medium |
58+
| <span id="1110">1110</span> | [Delete Nodes And Return Forest](https://leetcode.com/problems/delete-nodes-and-return-forest "删点成林") | [Go](https://github.com/openset/leetcode/tree/master/problems/delete-nodes-and-return-forest) | Medium |
59+
| <span id="1109">1109</span> | [Corporate Flight Bookings](https://leetcode.com/problems/corporate-flight-bookings "航班预订统计") | [Go](https://github.com/openset/leetcode/tree/master/problems/corporate-flight-bookings) | Medium |
60+
| <span id="1108">1108</span> | [Defanging an IP Address](https://leetcode.com/problems/defanging-an-ip-address "IP 地址无效化") | [Go](https://github.com/openset/leetcode/tree/master/problems/defanging-an-ip-address) | Easy |
5761
| <span id="1107">1107</span> | [New Users Daily Count](https://leetcode.com/problems/new-users-daily-count) 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/new-users-daily-count) | Medium |
5862
| <span id="1106">1106</span> | [Parsing A Boolean Expression](https://leetcode.com/problems/parsing-a-boolean-expression "解析布尔表达式") | [Go](https://github.com/openset/leetcode/tree/master/problems/parsing-a-boolean-expression) | Hard |
5963
| <span id="1105">1105</span> | [Filling Bookcase Shelves](https://leetcode.com/problems/filling-bookcase-shelves "填充书架") | [Go](https://github.com/openset/leetcode/tree/master/problems/filling-bookcase-shelves) | Medium |

Diff for: problems/corporate-flight-bookings/README.md

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<!--|This file generated by command(leetcode description); DO NOT EDIT. |-->
2+
<!--+----------------------------------------------------------------------+-->
3+
<!--|@author Openset <[email protected]> |-->
4+
<!--|@link https://github.com/openset |-->
5+
<!--|@home https://github.com/openset/leetcode |-->
6+
<!--+----------------------------------------------------------------------+-->
7+
8+
[< Previous](https://github.com/openset/leetcode/tree/master/problems/defanging-an-ip-address "Defanging an IP Address")
9+
                
10+
[Next >](https://github.com/openset/leetcode/tree/master/problems/delete-nodes-and-return-forest "Delete Nodes And Return Forest")
11+
12+
## 1109. Corporate Flight Bookings (Medium)
13+
14+
<p>There are <code>n</code> flights, and they are labeled&nbsp;from <code>1</code> to <code>n</code>.</p>
15+
16+
<p>We have a list of flight bookings.&nbsp; The <code>i</code>-th booking&nbsp;<code>bookings[i] = [i, j, k]</code>&nbsp;means that we booked <code>k</code> seats from flights labeled <code>i</code> to <code>j</code> inclusive.</p>
17+
18+
<p>Return an array <code>answer</code> of length <code>n</code>, representing the number of seats booked on each flight in order of their label.</p>
19+
20+
<p>&nbsp;</p>
21+
<p><strong>Example 1:</strong></p>
22+
23+
<pre>
24+
<strong>Input:</strong> bookings = [[1,2,10],[2,3,20],[2,5,25]], n = 5
25+
<strong>Output:</strong> [10,55,45,25,25]
26+
</pre>
27+
28+
<p>&nbsp;</p>
29+
<p><strong>Constraints:</strong></p>
30+
31+
<ul>
32+
<li><code>1 &lt;= bookings.length &lt;= 20000</code></li>
33+
<li><code>1 &lt;= bookings[i][0] &lt;= bookings[i][1] &lt;= n &lt;= 20000</code></li>
34+
<li><code>1 &lt;= bookings[i][2] &lt;= 10000</code></li>
35+
</ul>

Diff for: problems/defanging-an-ip-address/README.md

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<!--|This file generated by command(leetcode description); DO NOT EDIT. |-->
2+
<!--+----------------------------------------------------------------------+-->
3+
<!--|@author Openset <[email protected]> |-->
4+
<!--|@link https://github.com/openset |-->
5+
<!--|@home https://github.com/openset/leetcode |-->
6+
<!--+----------------------------------------------------------------------+-->
7+
8+
[< Previous](https://github.com/openset/leetcode/tree/master/problems/new-users-daily-count "New Users Daily Count")
9+
                
10+
[Next >](https://github.com/openset/leetcode/tree/master/problems/corporate-flight-bookings "Corporate Flight Bookings")
11+
12+
## 1108. Defanging an IP Address (Easy)
13+
14+
<p>Given a valid (IPv4) IP <code>address</code>, return a defanged version of that IP address.</p>
15+
16+
<p>A <em>defanged&nbsp;IP address</em>&nbsp;replaces every period <code>&quot;.&quot;</code> with <code>&quot;[.]&quot;</code>.</p>
17+
18+
<p>&nbsp;</p>
19+
<p><strong>Example 1:</strong></p>
20+
<pre><strong>Input:</strong> address = "1.1.1.1"
21+
<strong>Output:</strong> "1[.]1[.]1[.]1"
22+
</pre><p><strong>Example 2:</strong></p>
23+
<pre><strong>Input:</strong> address = "255.100.50.0"
24+
<strong>Output:</strong> "255[.]100[.]50[.]0"
25+
</pre>
26+
<p>&nbsp;</p>
27+
<p><strong>Constraints:</strong></p>
28+
29+
<ul>
30+
<li>The given <code>address</code> is a valid IPv4 address.</li>
31+
</ul>

Diff for: problems/delete-nodes-and-return-forest/README.md

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<!--|This file generated by command(leetcode description); DO NOT EDIT. |-->
2+
<!--+----------------------------------------------------------------------+-->
3+
<!--|@author Openset <[email protected]> |-->
4+
<!--|@link https://github.com/openset |-->
5+
<!--|@home https://github.com/openset/leetcode |-->
6+
<!--+----------------------------------------------------------------------+-->
7+
8+
[< Previous](https://github.com/openset/leetcode/tree/master/problems/corporate-flight-bookings "Corporate Flight Bookings")
9+
                
10+
[Next >](https://github.com/openset/leetcode/tree/master/problems/maximum-nesting-depth-of-two-valid-parentheses-strings "Maximum Nesting Depth of Two Valid Parentheses Strings")
11+
12+
## 1110. Delete Nodes And Return Forest (Medium)
13+
14+
<p>Given the <code>root</code>&nbsp;of a binary tree, each node in the tree has a distinct value.</p>
15+
16+
<p>After deleting&nbsp;all nodes with a value in <code>to_delete</code>, we are left with a forest (a&nbsp;disjoint union of trees).</p>
17+
18+
<p>Return the roots of the trees in the remaining forest.&nbsp; You may return the result in any order.</p>
19+
20+
<p>&nbsp;</p>
21+
<p><strong>Example 1:</strong></p>
22+
23+
<p><strong><img alt="" src="https://assets.leetcode.com/uploads/2019/07/01/screen-shot-2019-07-01-at-53836-pm.png" style="width: 237px; height: 150px;" /></strong></p>
24+
25+
<pre>
26+
<strong>Input:</strong> root = [1,2,3,4,5,6,7], to_delete = [3,5]
27+
<strong>Output:</strong> [[1,2,null,4],[6],[7]]
28+
</pre>
29+
30+
<p>&nbsp;</p>
31+
<p><strong>Constraints:</strong></p>
32+
33+
<ul>
34+
<li>The number of nodes in the given tree is at most <code>1000</code>.</li>
35+
<li>Each node has a distinct value between <code>1</code> and <code>1000</code>.</li>
36+
<li><code>to_delete.length &lt;= 1000</code></li>
37+
<li><code>to_delete</code> contains distinct values between <code>1</code> and <code>1000</code>.</li>
38+
</ul>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<!--|This file generated by command(leetcode description); DO NOT EDIT. |-->
2+
<!--+----------------------------------------------------------------------+-->
3+
<!--|@author Openset <[email protected]> |-->
4+
<!--|@link https://github.com/openset |-->
5+
<!--|@home https://github.com/openset/leetcode |-->
6+
<!--+----------------------------------------------------------------------+-->
7+
8+
[< Previous](https://github.com/openset/leetcode/tree/master/problems/delete-nodes-and-return-forest "Delete Nodes And Return Forest")
9+
                
10+
Next >
11+
12+
## 1111. Maximum Nesting Depth of Two Valid Parentheses Strings (Hard)
13+
14+
<p>A string is a <em>valid parentheses string</em>&nbsp;(denoted VPS) if and only if it consists of <code>&quot;(&quot;</code> and <code>&quot;)&quot;</code> characters only, and:</p>
15+
16+
<ul>
17+
<li>It is the empty string, or</li>
18+
<li>It can be written as&nbsp;<code>AB</code>&nbsp;(<code>A</code>&nbsp;concatenated with&nbsp;<code>B</code>), where&nbsp;<code>A</code>&nbsp;and&nbsp;<code>B</code>&nbsp;are VPS&#39;s, or</li>
19+
<li>It can be written as&nbsp;<code>(A)</code>, where&nbsp;<code>A</code>&nbsp;is a VPS.</li>
20+
</ul>
21+
22+
<p>We can&nbsp;similarly define the <em>nesting depth</em> <code>depth(S)</code> of any VPS <code>S</code> as follows:</p>
23+
24+
<ul>
25+
<li><code>depth(&quot;&quot;) = 0</code></li>
26+
<li><code>depth(A + B) = max(depth(A), depth(B))</code>, where <code>A</code> and <code>B</code> are VPS&#39;s</li>
27+
<li><code>depth(&quot;(&quot; + A + &quot;)&quot;) = 1 + depth(A)</code>, where <code>A</code> is a VPS.</li>
28+
</ul>
29+
30+
<p>For example,&nbsp; <code>&quot;&quot;</code>,&nbsp;<code>&quot;()()&quot;</code>, and&nbsp;<code>&quot;()(()())&quot;</code>&nbsp;are VPS&#39;s (with nesting depths 0, 1, and 2), and <code>&quot;)(&quot;</code> and <code>&quot;(()&quot;</code> are not VPS&#39;s.</p>
31+
32+
<p>&nbsp;</p>
33+
34+
<p>Given a VPS <font face="monospace">seq</font>, split it into two disjoint subsequences <code>A</code> and <code>B</code>, such that&nbsp;<code>A</code> and <code>B</code> are VPS&#39;s (and&nbsp;<code>A.length + B.length = seq.length</code>).</p>
35+
36+
<p>Now choose <strong>any</strong> such <code>A</code> and <code>B</code> such that&nbsp;<code>max(depth(A), depth(B))</code> is the minimum possible value.</p>
37+
38+
<p>Return an <code>answer</code> array (of length <code>seq.length</code>) that encodes such a&nbsp;choice of <code>A</code> and <code>B</code>:&nbsp; <code>answer[i] = 0</code> if <code>seq[i]</code> is part of <code>A</code>, else <code>answer[i] = 1</code>.&nbsp; Note that even though multiple answers may exist, you may return any of them.</p>
39+
40+
<p>&nbsp;</p>
41+
<p><strong>Example 1:</strong></p>
42+
43+
<pre>
44+
<strong>Input:</strong> seq = &quot;(()())&quot;
45+
<strong>Output:</strong> [0,1,1,1,1,0]
46+
</pre>
47+
48+
<p><strong>Example 2:</strong></p>
49+
50+
<pre>
51+
<strong>Input:</strong> seq = &quot;()(())()&quot;
52+
<strong>Output:</strong> [0,0,0,1,1,0,1,1]
53+
</pre>
54+
55+
<p>&nbsp;</p>
56+
<p><strong>Constraints:</strong></p>
57+
58+
<ul>
59+
<li><code>1 &lt;= text.size &lt;= 10000</code></li>
60+
</ul>

Diff for: problems/new-users-daily-count/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
[< Previous](https://github.com/openset/leetcode/tree/master/problems/parsing-a-boolean-expression "Parsing A Boolean Expression")
99

10-
Next >
10+
[Next >](https://github.com/openset/leetcode/tree/master/problems/defanging-an-ip-address "Defanging an IP Address")
1111

1212
## 1107. New Users Daily Count (Medium)
1313

0 commit comments

Comments
 (0)