Skip to content

Commit e86d0be

Browse files
author
Shuo
authored
Merge pull request #687 from openset/develop
Update: daily update
2 parents 9bc5e5a + 81806ae commit e86d0be

File tree

88 files changed

+554
-152
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+554
-152
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ LeetCode Problems' Solutions
103103
| <span id="1182">1182</span> | [Shortest Distance to Target Color](https://leetcode.com/problems/shortest-distance-to-target-color "与目标颜色间的最短距离") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/shortest-distance-to-target-color) | Medium |
104104
| <span id="1181">1181</span> | [Before and After Puzzle](https://leetcode.com/problems/before-and-after-puzzle "前后拼接") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/before-and-after-puzzle) | Medium |
105105
| <span id="1180">1180</span> | [Count Substrings with Only One Distinct Letter](https://leetcode.com/problems/count-substrings-with-only-one-distinct-letter "统计只含单一字母的子串") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/count-substrings-with-only-one-distinct-letter) | Easy |
106-
| <span id="1179">1179</span> | [Reformat Department Table](https://leetcode.com/problems/reformat-department-table) | [MySQL](https://github.com/openset/leetcode/tree/master/problems/reformat-department-table) | Easy |
106+
| <span id="1179">1179</span> | [Reformat Department Table](https://leetcode.com/problems/reformat-department-table "重新格式化部门表") | [MySQL](https://github.com/openset/leetcode/tree/master/problems/reformat-department-table) | Easy |
107107
| <span id="1178">1178</span> | [Number of Valid Words for Each Puzzle](https://leetcode.com/problems/number-of-valid-words-for-each-puzzle "猜字谜") | [Go](https://github.com/openset/leetcode/tree/master/problems/number-of-valid-words-for-each-puzzle) | Hard |
108108
| <span id="1177">1177</span> | [Can Make Palindrome from Substring](https://leetcode.com/problems/can-make-palindrome-from-substring "构建回文串检测") | [Go](https://github.com/openset/leetcode/tree/master/problems/can-make-palindrome-from-substring) | Medium |
109109
| <span id="1176">1176</span> | [Diet Plan Performance](https://leetcode.com/problems/diet-plan-performance "健身计划评估") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/diet-plan-performance) | Easy |

problems/additive-number/README.md

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,32 @@
1919

2020
<p><b>Note:</b> Numbers in the additive sequence <b>cannot</b> have leading zeros, so sequence <code>1, 2, 03</code> or <code>1, 02, 3</code> is invalid.</p>
2121

22-
<p><b>Example 1:</b></p>
22+
<p>&nbsp;</p>
23+
<p><strong>Example 1:</strong></p>
2324

2425
<pre>
25-
<b>Input:</b> <code>&quot;112358&quot;</code>
26-
<b>Output:</b> true
27-
<strong>Explanation: </strong>The digits can form an additive sequence: <code>1, 1, 2, 3, 5, 8</code>.
26+
<strong>Input:</strong> &quot;112358&quot;
27+
<strong>Output:</strong> true
28+
<strong>Explanation:</strong> The digits can form an additive sequence: 1, 1, 2, 3, 5, 8.
2829
&nbsp; 1 + 1 = 2, 1 + 2 = 3, 2 + 3 = 5, 3 + 5 = 8
2930
</pre>
3031

31-
<p><b>Example 2:</b></p>
32+
<p><strong>Example 2:</strong></p>
3233

3334
<pre>
34-
<b>Input:</b> <code>&quot;199100199&quot;</code>
35-
<b>Output:</b> true
36-
<strong>Explanation: </strong>The additive sequence is: <code>1, 99, 100, 199</code><span style="font-family: sans-serif, Arial, Verdana, &quot;Trebuchet MS&quot;;">.</span>&nbsp;
37-
&nbsp; 1 + 99 = 100, 99 + 100 = 199</pre>
35+
<strong>Input:</strong> &quot;199100199&quot;
36+
<strong>Output:</strong> true
37+
<strong>Explanation:</strong> The additive sequence is: 1, 99, 100, 199.&nbsp;
38+
&nbsp; 1 + 99 = 100, 99 + 100 = 199
39+
</pre>
40+
41+
<p>&nbsp;</p>
42+
<p><strong>Constraints:</strong></p>
43+
44+
<ul>
45+
<li><font face="monospace"><code>num</code>&nbsp;</font>consists only of digits <code>&#39;0&#39;-&#39;9&#39;</code>.</li>
46+
<li><code>1 &lt;= num.length &lt;= 35</code></li>
47+
</ul>
3848

3949
<p><b>Follow up:</b><br />
4050
How would you handle overflow for very large input integers?</p>

problems/alphabet-board-path/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,18 @@
4646
<li><code>1 &lt;= target.length &lt;= 100</code></li>
4747
<li><code>target</code> consists only of English lowercase letters.</li>
4848
</ul>
49+
50+
### Related Topics
51+
[[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)]
52+
[[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)]
53+
54+
### Hints
55+
<details>
56+
<summary>Hint 1</summary>
57+
Create a hashmap from letter to position on the board.
58+
</details>
59+
60+
<details>
61+
<summary>Hint 2</summary>
62+
Now for each letter, try moving there in steps, where at each step you check if it is inside the boundaries of the board.
63+
</details>

problems/binary-tree-coloring-game/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,14 @@
4242
### Related Topics
4343
[[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)]
4444
[[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)]
45+
46+
### Hints
47+
<details>
48+
<summary>Hint 1</summary>
49+
The best move y must be immediately adjacent to x, since it locks out that subtree.
50+
</details>
51+
52+
<details>
53+
<summary>Hint 2</summary>
54+
Can you count each of (up to) 3 different subtrees neighboring x?
55+
</details>

problems/brace-expansion-ii/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
<li>When we concatenate two expressions, we take the set of possible concatenations between two words where the first word comes from the first expression and the second word comes from the second expression.
3232
<ul>
3333
<li><code>R(&quot;{a,b}{c,d}&quot;) = {&quot;ac&quot;,&quot;ad&quot;,&quot;bc&quot;,&quot;bd&quot;}</code></li>
34-
<li><code>R(&quot;{a{b,c}}{{d,e}f{g,h}}&quot;) = R(&quot;{ab,ac}{dfg,dfh,efg,efh}&quot;) = {&quot;abdfg&quot;, &quot;abdfh&quot;, &quot;abefg&quot;, &quot;abefh&quot;, &quot;acdfg&quot;, &quot;acdfh&quot;, &quot;acefg&quot;, &quot;acefh&quot;}</code></li>
34+
<li><code>R(&quot;a{b,c}{d,e}f{g,h}&quot;)&nbsp;= {&quot;abdfg&quot;, &quot;abdfh&quot;, &quot;abefg&quot;, &quot;abefh&quot;, &quot;acdfg&quot;, &quot;acdfh&quot;, &quot;acefg&quot;, &quot;acefh&quot;}</code></li>
3535
</ul>
3636
</li>
3737
</ul>
@@ -52,8 +52,8 @@
5252
<p><strong>Example 1:</strong></p>
5353

5454
<pre>
55-
<strong>Input: </strong><span id="example-input-1-1">&quot;{a,b}{c{d,e}}&quot;</span>
56-
<strong>Output: </strong><span id="example-output-1">[&quot;acd&quot;,&quot;ace&quot;,&quot;bcd&quot;,&quot;bce&quot;]</span>
55+
<strong>Input: </strong><span id="example-input-1-1">&quot;{a,b}{c,{d,e}}&quot;</span>
56+
<strong>Output: </strong><span id="example-output-1">[&quot;ac&quot;,&quot;ad&quot;,&quot;ae&quot;,&quot;bc&quot;,&quot;bd&quot;,&quot;be&quot;]</span>
5757
</pre>
5858

5959
<div>
@@ -70,7 +70,7 @@
7070
<p><strong>Constraints:</strong></p>
7171

7272
<ol>
73-
<li><code>1 &lt;= expression.length &lt;= 50</code></li>
73+
<li><code>1 &lt;= expression.length &lt;= 60</code></li>
7474
<li><code>expression[i]</code> consists of <code>&#39;{&#39;</code>, <code>&#39;}&#39;</code>, <code>&#39;,&#39;</code>or lowercase English letters.</li>
7575
<li>The given&nbsp;<code>expression</code>&nbsp;represents a set of words based on the grammar given in the description.</li>
7676
</ol>

problems/building-h2o/README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99

1010
[Next >](https://github.com/openset/leetcode/tree/master/problems/number-of-days-in-a-month "Number of Days in a Month")
1111

12-
## [1117. Building H2O (Hard)](https://leetcode.com/problems/building-h2o "H2O 生成")
12+
## [1117. Building H2O (Medium)](https://leetcode.com/problems/building-h2o "H2O 生成")
1313

14-
<p>There are two kinds of threads, <code>oxygen</code> and <code>hydrogen</code>. Your goal is to group these threads to form water molecules.&nbsp;There is a barrier where each thread has to&nbsp;wait until a complete molecule can be formed. Hydrogen and oxygen threads will be given a <code>releaseHydrogen</code>&nbsp;and <code>releaseOxygen</code>&nbsp;method respectfully, which will allow them to pass the barrier. These threads should pass the barrier in groups of three, and they must be able to immediately bond with each other to form a water molecule.&nbsp;You must guarantee that all the threads from one molecule bond <em>before</em> any other threads from the next molecule do.</p>
14+
<p>There are two kinds of threads, <code>oxygen</code> and <code>hydrogen</code>. Your goal is to group these threads to form water molecules.&nbsp;There is a barrier where each thread has to&nbsp;wait until a complete molecule can be formed. Hydrogen and oxygen threads will be given <code>releaseHydrogen</code>&nbsp;and <code>releaseOxygen</code>&nbsp;methods respectively, which will allow them to pass the barrier. These threads should pass the barrier in groups of three, and they must be able to immediately bond with each other to form a water molecule.&nbsp;You must guarantee that all the threads from one molecule bond <em>before</em> any other threads from the next molecule do.</p>
1515

1616
<p>In other words:</p>
1717

@@ -20,6 +20,8 @@
2020
<li>If a hydrogen thread arrives at the barrier when no other threads are present, it has to wait for an oxygen thread and another hydrogen thread.</li>
2121
</ul>
2222

23+
<p>We don&rsquo;t have to worry about matching the threads up explicitly; that is, the threads do not necessarily know which other threads they are paired up with. The key is just that threads pass the barrier in complete sets; thus, if we examine the sequence of threads that bond and divide them into groups of three, each group should contain one oxygen and two hydrogen threads.</p>
24+
2325
<p>Write synchronization code for oxygen and hydrogen molecules that enforces these constraints.</p>
2426

2527
<div>
@@ -50,7 +52,7 @@
5052
<p><strong>Constraints:</strong></p>
5153

5254
<ul>
53-
<li>Total length of input string will be 3<em>n</em>, where 1 &le;&nbsp;<em>n</em>&nbsp;&le; 50.</li>
55+
<li>Total length of input string will be 3<em>n</em>, where 1 &le;&nbsp;<em>n</em>&nbsp;&le; 20.</li>
5456
<li>Total number of <code>H</code> will be 2<em>n</em>&nbsp;in the input string.</li>
5557
<li>Total number of <code>O</code> will&nbsp;be <em>n</em>&nbsp;in the input&nbsp;string.</li>
5658
</ul>

problems/bulls-and-cows/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
[Next >](https://github.com/openset/leetcode/tree/master/problems/longest-increasing-subsequence "Longest Increasing Subsequence")
1111

12-
## [299. Bulls and Cows (Medium)](https://leetcode.com/problems/bulls-and-cows "猜数字游戏")
12+
## [299. Bulls and Cows (Easy)](https://leetcode.com/problems/bulls-and-cows "猜数字游戏")
1313

1414
<p>You are playing the following <a href="https://en.wikipedia.org/wiki/Bulls_and_Cows" target="_blank">Bulls and Cows</a> game with your friend: You write down a number and ask your friend to guess what the number is. Each time your friend makes a guess, you provide a hint that indicates how many digits in said guess match your secret number exactly in both digit and position (called &quot;bulls&quot;) and how many digits match the secret number but locate in the wrong position (called &quot;cows&quot;). Your friend will use successive guesses and hints to eventually derive the secret number.</p>
1515

problems/corporate-flight-bookings/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,7 @@
3333
<li><code>1 &lt;= bookings[i][0] &lt;= bookings[i][1] &lt;= n &lt;= 20000</code></li>
3434
<li><code>1 &lt;= bookings[i][2] &lt;= 10000</code></li>
3535
</ul>
36+
37+
### Related Topics
38+
[[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)]
39+
[[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)]

problems/count-vowels-permutation/README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
Next >
1111

12-
## [5216. Count Vowels Permutation (Hard)](https://leetcode.com/problems/count-vowels-permutation "统计元音字母序列的数目")
12+
## [1220. Count Vowels Permutation (Hard)](https://leetcode.com/problems/count-vowels-permutation "统计元音字母序列的数目")
1313

1414
<p>Given an integer <code>n</code>, your task is to count how many strings of length <code>n</code> can be formed under the following rules:</p>
1515

@@ -54,6 +54,9 @@ Next >
5454
<li><code>1 &lt;= n &lt;= 2 * 10^4</code></li>
5555
</ul>
5656

57+
### Related Topics
58+
[[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)]
59+
5760
### Hints
5861
<details>
5962
<summary>Hint 1</summary>

problems/critical-connections-in-a-network/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@
3838
<li>There are no repeated connections.</li>
3939
</ul>
4040

41+
### Related Topics
42+
[[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)]
43+
4144
### Hints
4245
<details>
4346
<summary>Hint 1</summary>

0 commit comments

Comments
 (0)