Skip to content

Add: new #604

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ LeetCode Problems' Solutions

| # | Title | Solution | Difficulty |
| :-: | - | - | :-: |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
Expand Down
35 changes: 35 additions & 0 deletions problems/corporate-flight-bookings/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!--|This file generated by command(leetcode description); DO NOT EDIT. |-->
<!--+----------------------------------------------------------------------+-->
<!--|@author Openset <[email protected]> |-->
<!--|@link https://github.com/openset |-->
<!--|@home https://github.com/openset/leetcode |-->
<!--+----------------------------------------------------------------------+-->

[< Previous](https://github.com/openset/leetcode/tree/master/problems/defanging-an-ip-address "Defanging an IP Address")

[Next >](https://github.com/openset/leetcode/tree/master/problems/delete-nodes-and-return-forest "Delete Nodes And Return Forest")

## 1109. Corporate Flight Bookings (Medium)

<p>There are <code>n</code> flights, and they are labeled&nbsp;from <code>1</code> to <code>n</code>.</p>

<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>

<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>

<p>&nbsp;</p>
<p><strong>Example 1:</strong></p>

<pre>
<strong>Input:</strong> bookings = [[1,2,10],[2,3,20],[2,5,25]], n = 5
<strong>Output:</strong> [10,55,45,25,25]
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
<li><code>1 &lt;= bookings.length &lt;= 20000</code></li>
<li><code>1 &lt;= bookings[i][0] &lt;= bookings[i][1] &lt;= n &lt;= 20000</code></li>
<li><code>1 &lt;= bookings[i][2] &lt;= 10000</code></li>
</ul>
31 changes: 31 additions & 0 deletions problems/defanging-an-ip-address/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!--|This file generated by command(leetcode description); DO NOT EDIT. |-->
<!--+----------------------------------------------------------------------+-->
<!--|@author Openset <[email protected]> |-->
<!--|@link https://github.com/openset |-->
<!--|@home https://github.com/openset/leetcode |-->
<!--+----------------------------------------------------------------------+-->

[< Previous](https://github.com/openset/leetcode/tree/master/problems/new-users-daily-count "New Users Daily Count")

[Next >](https://github.com/openset/leetcode/tree/master/problems/corporate-flight-bookings "Corporate Flight Bookings")

## 1108. Defanging an IP Address (Easy)

<p>Given a valid (IPv4) IP <code>address</code>, return a defanged version of that IP address.</p>

<p>A <em>defanged&nbsp;IP address</em>&nbsp;replaces every period <code>&quot;.&quot;</code> with <code>&quot;[.]&quot;</code>.</p>

<p>&nbsp;</p>
<p><strong>Example 1:</strong></p>
<pre><strong>Input:</strong> address = "1.1.1.1"
<strong>Output:</strong> "1[.]1[.]1[.]1"
</pre><p><strong>Example 2:</strong></p>
<pre><strong>Input:</strong> address = "255.100.50.0"
<strong>Output:</strong> "255[.]100[.]50[.]0"
</pre>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
<li>The given <code>address</code> is a valid IPv4 address.</li>
</ul>
38 changes: 38 additions & 0 deletions problems/delete-nodes-and-return-forest/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<!--|This file generated by command(leetcode description); DO NOT EDIT. |-->
<!--+----------------------------------------------------------------------+-->
<!--|@author Openset <[email protected]> |-->
<!--|@link https://github.com/openset |-->
<!--|@home https://github.com/openset/leetcode |-->
<!--+----------------------------------------------------------------------+-->

[< Previous](https://github.com/openset/leetcode/tree/master/problems/corporate-flight-bookings "Corporate Flight Bookings")

[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")

## 1110. Delete Nodes And Return Forest (Medium)

<p>Given the <code>root</code>&nbsp;of a binary tree, each node in the tree has a distinct value.</p>

<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>

<p>Return the roots of the trees in the remaining forest.&nbsp; You may return the result in any order.</p>

<p>&nbsp;</p>
<p><strong>Example 1:</strong></p>

<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>

<pre>
<strong>Input:</strong> root = [1,2,3,4,5,6,7], to_delete = [3,5]
<strong>Output:</strong> [[1,2,null,4],[6],[7]]
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
<li>The number of nodes in the given tree is at most <code>1000</code>.</li>
<li>Each node has a distinct value between <code>1</code> and <code>1000</code>.</li>
<li><code>to_delete.length &lt;= 1000</code></li>
<li><code>to_delete</code> contains distinct values between <code>1</code> and <code>1000</code>.</li>
</ul>
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<!--|This file generated by command(leetcode description); DO NOT EDIT. |-->
<!--+----------------------------------------------------------------------+-->
<!--|@author Openset <[email protected]> |-->
<!--|@link https://github.com/openset |-->
<!--|@home https://github.com/openset/leetcode |-->
<!--+----------------------------------------------------------------------+-->

[< Previous](https://github.com/openset/leetcode/tree/master/problems/delete-nodes-and-return-forest "Delete Nodes And Return Forest")

Next >

## 1111. Maximum Nesting Depth of Two Valid Parentheses Strings (Hard)

<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>

<ul>
<li>It is the empty string, or</li>
<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>
<li>It can be written as&nbsp;<code>(A)</code>, where&nbsp;<code>A</code>&nbsp;is a VPS.</li>
</ul>

<p>We can&nbsp;similarly define the <em>nesting depth</em> <code>depth(S)</code> of any VPS <code>S</code> as follows:</p>

<ul>
<li><code>depth(&quot;&quot;) = 0</code></li>
<li><code>depth(A + B) = max(depth(A), depth(B))</code>, where <code>A</code> and <code>B</code> are VPS&#39;s</li>
<li><code>depth(&quot;(&quot; + A + &quot;)&quot;) = 1 + depth(A)</code>, where <code>A</code> is a VPS.</li>
</ul>

<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>

<p>&nbsp;</p>

<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>

<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>

<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>

<p>&nbsp;</p>
<p><strong>Example 1:</strong></p>

<pre>
<strong>Input:</strong> seq = &quot;(()())&quot;
<strong>Output:</strong> [0,1,1,1,1,0]
</pre>

<p><strong>Example 2:</strong></p>

<pre>
<strong>Input:</strong> seq = &quot;()(())()&quot;
<strong>Output:</strong> [0,0,0,1,1,0,1,1]
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
<li><code>1 &lt;= text.size &lt;= 10000</code></li>
</ul>
2 changes: 1 addition & 1 deletion problems/new-users-daily-count/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

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

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

## 1107. New Users Daily Count (Medium)

Expand Down