Skip to content

Commit a376670

Browse files
author
Shuo
authored
Merge pull request #845 from openset/develop
A: new
2 parents 1b37a9e + 5792575 commit a376670

File tree

317 files changed

+3368
-586
lines changed

Some content is hidden

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

317 files changed

+3368
-586
lines changed

Diff for: README.md

+32-1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,37 @@ LeetCode Problems' Solutions
7878

7979
| # | Title | Solution | Difficulty |
8080
| :-: | - | - | :-: |
81+
| <span id="2076">2076</span> | [Process Restricted Friend Requests](https://leetcode.com/problems/process-restricted-friend-requests "处理含限制条件的好友请求") | [Go](problems/process-restricted-friend-requests) | Hard |
82+
| <span id="2075">2075</span> | [Decode the Slanted Ciphertext](https://leetcode.com/problems/decode-the-slanted-ciphertext "解码斜向换位密码") | [Go](problems/decode-the-slanted-ciphertext) | Medium |
83+
| <span id="2074">2074</span> | [Reverse Nodes in Even Length Groups](https://leetcode.com/problems/reverse-nodes-in-even-length-groups "反转偶数长度组的节点") | [Go](problems/reverse-nodes-in-even-length-groups) | Medium |
84+
| <span id="2073">2073</span> | [Time Needed to Buy Tickets](https://leetcode.com/problems/time-needed-to-buy-tickets "买票需要的时间") | [Go](problems/time-needed-to-buy-tickets) | Easy |
85+
| <span id="2072">2072</span> | [The Winner University](https://leetcode.com/problems/the-winner-university) 🔒 | [MySQL](problems/the-winner-university) | Easy |
86+
| <span id="2071">2071</span> | [Maximum Number of Tasks You Can Assign](https://leetcode.com/problems/maximum-number-of-tasks-you-can-assign "你可以安排的最多任务数目") | [Go](problems/maximum-number-of-tasks-you-can-assign) | Hard |
87+
| <span id="2070">2070</span> | [Most Beautiful Item for Each Query](https://leetcode.com/problems/most-beautiful-item-for-each-query "每一个查询的最大美丽值") | [Go](problems/most-beautiful-item-for-each-query) | Medium |
88+
| <span id="2069">2069</span> | [Walking Robot Simulation II](https://leetcode.com/problems/walking-robot-simulation-ii "模拟行走机器人 II") | [Go](problems/walking-robot-simulation-ii) | Medium |
89+
| <span id="2068">2068</span> | [Check Whether Two Strings are Almost Equivalent](https://leetcode.com/problems/check-whether-two-strings-are-almost-equivalent "检查两个字符串是否几乎相等") | [Go](problems/check-whether-two-strings-are-almost-equivalent) | Easy |
90+
| <span id="2067">2067</span> | [Number of Equal Count Substrings](https://leetcode.com/problems/number-of-equal-count-substrings) 🔒 | [Go](problems/number-of-equal-count-substrings) | Medium |
91+
| <span id="2066">2066</span> | [Account Balance](https://leetcode.com/problems/account-balance) 🔒 | [MySQL](problems/account-balance) | Medium |
92+
| <span id="2065">2065</span> | [Maximum Path Quality of a Graph](https://leetcode.com/problems/maximum-path-quality-of-a-graph "最大化一张图中的路径价值") | [Go](problems/maximum-path-quality-of-a-graph) | Hard |
93+
| <span id="2064">2064</span> | [Minimized Maximum of Products Distributed to Any Store](https://leetcode.com/problems/minimized-maximum-of-products-distributed-to-any-store "分配给商店的最多商品的最小值") | [Go](problems/minimized-maximum-of-products-distributed-to-any-store) | Medium |
94+
| <span id="2063">2063</span> | [Vowels of All Substrings](https://leetcode.com/problems/vowels-of-all-substrings "所有子字符串中的元音") | [Go](problems/vowels-of-all-substrings) | Medium |
95+
| <span id="2062">2062</span> | [Count Vowel Substrings of a String](https://leetcode.com/problems/count-vowel-substrings-of-a-string "统计字符串中的元音子字符串") | [Go](problems/count-vowel-substrings-of-a-string) | Easy |
96+
| <span id="2061">2061</span> | [Number of Spaces Cleaning Robot Cleaned](https://leetcode.com/problems/number-of-spaces-cleaning-robot-cleaned) 🔒 | [Go](problems/number-of-spaces-cleaning-robot-cleaned) | Medium |
97+
| <span id="2060">2060</span> | [Check if an Original String Exists Given Two Encoded Strings](https://leetcode.com/problems/check-if-an-original-string-exists-given-two-encoded-strings "同源字符串检测") | [Go](problems/check-if-an-original-string-exists-given-two-encoded-strings) | Hard |
98+
| <span id="2059">2059</span> | [Minimum Operations to Convert Number](https://leetcode.com/problems/minimum-operations-to-convert-number "转化数字的最小运算数") | [Go](problems/minimum-operations-to-convert-number) | Medium |
99+
| <span id="2058">2058</span> | [Find the Minimum and Maximum Number of Nodes Between Critical Points](https://leetcode.com/problems/find-the-minimum-and-maximum-number-of-nodes-between-critical-points "找出临界点之间的最小和最大距离") | [Go](problems/find-the-minimum-and-maximum-number-of-nodes-between-critical-points) | Medium |
100+
| <span id="2057">2057</span> | [Smallest Index With Equal Value](https://leetcode.com/problems/smallest-index-with-equal-value "值相等的最小索引") | [Go](problems/smallest-index-with-equal-value) | Easy |
101+
| <span id="2056">2056</span> | [Number of Valid Move Combinations On Chessboard](https://leetcode.com/problems/number-of-valid-move-combinations-on-chessboard "棋盘上有效移动组合的数目") | [Go](problems/number-of-valid-move-combinations-on-chessboard) | Hard |
102+
| <span id="2055">2055</span> | [Plates Between Candles](https://leetcode.com/problems/plates-between-candles "蜡烛之间的盘子") | [Go](problems/plates-between-candles) | Medium |
103+
| <span id="2054">2054</span> | [Two Best Non-Overlapping Events](https://leetcode.com/problems/two-best-non-overlapping-events "两个最好的不重叠活动") | [Go](problems/two-best-non-overlapping-events) | Medium |
104+
| <span id="2053">2053</span> | [Kth Distinct String in an Array](https://leetcode.com/problems/kth-distinct-string-in-an-array "数组中第 K 个独一无二的字符串") | [Go](problems/kth-distinct-string-in-an-array) | Easy |
105+
| <span id="2052">2052</span> | [Minimum Cost to Separate Sentence Into Rows](https://leetcode.com/problems/minimum-cost-to-separate-sentence-into-rows) 🔒 | [Go](problems/minimum-cost-to-separate-sentence-into-rows) | Medium |
106+
| <span id="2051">2051</span> | [The Category of Each Member in the Store](https://leetcode.com/problems/the-category-of-each-member-in-the-store) 🔒 | [MySQL](problems/the-category-of-each-member-in-the-store) | Medium |
107+
| <span id="2050">2050</span> | [Parallel Courses III](https://leetcode.com/problems/parallel-courses-iii "并行课程 III") | [Go](problems/parallel-courses-iii) | Hard |
108+
| <span id="2049">2049</span> | [Count Nodes With the Highest Score](https://leetcode.com/problems/count-nodes-with-the-highest-score "统计最高分的节点数目") | [Go](problems/count-nodes-with-the-highest-score) | Medium |
109+
| <span id="2048">2048</span> | [Next Greater Numerically Balanced Number](https://leetcode.com/problems/next-greater-numerically-balanced-number "下一个更大的数值平衡数") | [Go](problems/next-greater-numerically-balanced-number) | Medium |
110+
| <span id="2047">2047</span> | [Number of Valid Words in a Sentence](https://leetcode.com/problems/number-of-valid-words-in-a-sentence "句子中的有效单词数") | [Go](problems/number-of-valid-words-in-a-sentence) | Easy |
111+
| <span id="2046">2046</span> | [Sort Linked List Already Sorted Using Absolute Values](https://leetcode.com/problems/sort-linked-list-already-sorted-using-absolute-values) 🔒 | [Go](problems/sort-linked-list-already-sorted-using-absolute-values) | Medium |
81112
| <span id="2045">2045</span> | [Second Minimum Time to Reach Destination](https://leetcode.com/problems/second-minimum-time-to-reach-destination "到达目的地的第二短时间") | [Go](problems/second-minimum-time-to-reach-destination) | Hard |
82113
| <span id="2044">2044</span> | [Count Number of Maximum Bitwise-OR Subsets](https://leetcode.com/problems/count-number-of-maximum-bitwise-or-subsets "统计按位或能得到最大值的子集数目") | [Go](problems/count-number-of-maximum-bitwise-or-subsets) | Medium |
83114
| <span id="2043">2043</span> | [Simple Bank System](https://leetcode.com/problems/simple-bank-system "简易银行系统") | [Go](problems/simple-bank-system) | Medium |
@@ -158,7 +189,7 @@ LeetCode Problems' Solutions
158189
| <span id="1968">1968</span> | [Array With Elements Not Equal to Average of Neighbors](https://leetcode.com/problems/array-with-elements-not-equal-to-average-of-neighbors "构造元素不等于两相邻元素平均值的数组") | [Go](problems/array-with-elements-not-equal-to-average-of-neighbors) | Medium |
159190
| <span id="1967">1967</span> | [Number of Strings That Appear as Substrings in Word](https://leetcode.com/problems/number-of-strings-that-appear-as-substrings-in-word "作为子字符串出现在单词中的字符串数目") | [Go](problems/number-of-strings-that-appear-as-substrings-in-word) | Easy |
160191
| <span id="1966">1966</span> | [Binary Searchable Numbers in an Unsorted Array](https://leetcode.com/problems/binary-searchable-numbers-in-an-unsorted-array) 🔒 | [Go](problems/binary-searchable-numbers-in-an-unsorted-array) | Medium |
161-
| <span id="1965">1965</span> | [Employees With Missing Information](https://leetcode.com/problems/employees-with-missing-information) 🔒 | [MySQL](problems/employees-with-missing-information) | Easy |
192+
| <span id="1965">1965</span> | [Employees With Missing Information](https://leetcode.com/problems/employees-with-missing-information "丢失信息的雇员") 🔒 | [MySQL](problems/employees-with-missing-information) | Easy |
162193
| <span id="1964">1964</span> | [Find the Longest Valid Obstacle Course at Each Position](https://leetcode.com/problems/find-the-longest-valid-obstacle-course-at-each-position "找出到每个位置为止最长的有效障碍赛跑路线") | [Go](problems/find-the-longest-valid-obstacle-course-at-each-position) | Hard |
163194
| <span id="1963">1963</span> | [Minimum Number of Swaps to Make the String Balanced](https://leetcode.com/problems/minimum-number-of-swaps-to-make-the-string-balanced "使字符串平衡的最小交换次数") | [Go](problems/minimum-number-of-swaps-to-make-the-string-balanced) | Medium |
164195
| <span id="1962">1962</span> | [Remove Stones to Minimize the Total](https://leetcode.com/problems/remove-stones-to-minimize-the-total "移除石子使总数最小") | [Go](problems/remove-stones-to-minimize-the-total) | Medium |

Diff for: problems/account-balance/README.md

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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](../maximum-path-quality-of-a-graph "Maximum Path Quality of a Graph")
9+
                
10+
[Next >](../number-of-equal-count-substrings "Number of Equal Count Substrings")
11+
12+
## [2066. Account Balance (Medium)](https://leetcode.com/problems/account-balance "")
13+
14+
15+
16+
### Related Topics
17+
[[Database](../../tag/database/README.md)]

Diff for: problems/account-balance/mysql_schemas.sql

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Create table If Not Exists Transactions (account_id int, day date, type ENUM('Deposit', 'Withdraw'), amount int);
2+
Truncate table Transactions;
3+
insert into Transactions (account_id, day, type, amount) values ('1', '2021-11-07', 'Deposit', '2000');
4+
insert into Transactions (account_id, day, type, amount) values ('1', '2021-11-09', 'Withdraw', '1000');
5+
insert into Transactions (account_id, day, type, amount) values ('1', '2021-11-11', 'Deposit', '3000');
6+
insert into Transactions (account_id, day, type, amount) values ('2', '2021-12-07', 'Deposit', '7000');
7+
insert into Transactions (account_id, day, type, amount) values ('2', '2021-12-12', 'Withdraw', '7000');

Diff for: problems/accounts-merge/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
<strong>Input:</strong> accounts = [[&quot;John&quot;,&quot;[email protected]&quot;,&quot;[email protected]&quot;],[&quot;John&quot;,&quot;[email protected]&quot;,&quot;[email protected]&quot;],[&quot;Mary&quot;,&quot;[email protected]&quot;],[&quot;John&quot;,&quot;[email protected]&quot;]]
2525
<strong>Output:</strong> [[&quot;John&quot;,&quot;[email protected]&quot;,&quot;[email protected]&quot;,&quot;[email protected]&quot;],[&quot;Mary&quot;,&quot;[email protected]&quot;],[&quot;John&quot;,&quot;[email protected]&quot;]]
2626
<strong>Explanation:</strong>
27-
The first and third John&#39;s are the same person as they have the common email &quot;[email protected]&quot;.
28-
The second John and Mary are different people as none of their email addresses are used by other accounts.
27+
The first and second John&#39;s are the same person as they have the common email &quot;[email protected]&quot;.
28+
The third John and Mary are different people as none of their email addresses are used by other accounts.
2929
We could return these lists in any order, for example the answer [[&#39;Mary&#39;, &#39;[email protected]&#39;], [&#39;John&#39;, &#39;[email protected]&#39;],
3030
[&#39;John&#39;, &#39;[email protected]&#39;, &#39;[email protected]&#39;, &#39;[email protected]&#39;]] would still be accepted.
3131
</pre>

Diff for: problems/all-the-pairs-with-the-maximum-number-of-common-followers/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@
1212
## [1951. All the Pairs With the Maximum Number of Common Followers (Medium)](https://leetcode.com/problems/all-the-pairs-with-the-maximum-number-of-common-followers "查询具有最多共同关注者的所有两两结对组")
1313

1414

15+
16+
### Related Topics
17+
[[Database](../../tag/database/README.md)]

Diff for: problems/basic-calculator/README.md

+5-6
Original file line numberDiff line numberDiff line change
@@ -41,25 +41,24 @@
4141
<p><strong>Constraints:</strong></p>
4242

4343
<ul>
44-
<li><code>1 &lt;= s.length &lt;= 3&nbsp;* 10<sup>5</sup></code></li>
44+
<li><code>1 &lt;= s.length &lt;= 3 * 10<sup>5</sup></code></li>
4545
<li><code>s</code> consists of digits, <code>&#39;+&#39;</code>, <code>&#39;-&#39;</code>, <code>&#39;(&#39;</code>, <code>&#39;)&#39;</code>, and <code>&#39; &#39;</code>.</li>
4646
<li><code>s</code> represents a valid expression.</li>
47-
<li><code>&#39;+&#39;</code> is not used as a unary operation.</li>
48-
<li><code>&#39;-&#39;</code> could be used as a unary operation and in this case, it will not be used directly after a +ve or -ve signs (will be inside parentheses).</li>
47+
<li><code>&#39;+&#39;</code> is <strong>not</strong> used as a unary operation (i.e., <code>&quot;+1&quot;</code> and <code>&quot;+(2 + 3)&quot;</code> is invalid).</li>
48+
<li><code>&#39;-&#39;</code> could be used as a unary operation (i.e., <code>&quot;-1&quot;</code> and <code>&quot;-(2 + 3)&quot;</code> is valid).</li>
4949
<li>There will be no two consecutive operators in the input.</li>
5050
<li>Every number and running calculation will fit in a signed 32-bit integer.</li>
5151
</ul>
5252

5353
### Related Topics
54-
[[Math](../../tag/math/README.md)]
55-
[[String](../../tag/string/README.md)]
5654
[[Stack](../../tag/stack/README.md)]
5755
[[Recursion](../../tag/recursion/README.md)]
56+
[[Math](../../tag/math/README.md)]
57+
[[String](../../tag/string/README.md)]
5858

5959
### Similar Questions
6060
1. [Evaluate Reverse Polish Notation](../evaluate-reverse-polish-notation) (Medium)
6161
1. [Basic Calculator II](../basic-calculator-ii) (Medium)
6262
1. [Different Ways to Add Parentheses](../different-ways-to-add-parentheses) (Medium)
6363
1. [Expression Add Operators](../expression-add-operators) (Hard)
6464
1. [Basic Calculator III](../basic-calculator-iii) (Hard)
65-
1. [The Score of Students Solving Math Expression](../the-score-of-students-solving-math-expression) (Hard)

Diff for: problems/binary-tree-maximum-path-sum/README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
<p>The <strong>path sum</strong> of a path is the sum of the node&#39;s values in the path.</p>
1717

18-
<p>Given the <code>root</code> of a binary tree, return <em>the maximum <strong>path sum</strong> of any path</em>.</p>
18+
<p>Given the <code>root</code> of a binary tree, return <em>the maximum <strong>path sum</strong> of any <strong>non-empty</strong> path</em>.</p>
1919

2020
<p>&nbsp;</p>
2121
<p><strong>Example 1:</strong></p>
@@ -43,13 +43,14 @@
4343
</ul>
4444

4545
### Related Topics
46+
[[Dynamic Programming](../../tag/dynamic-programming/README.md)]
4647
[[Tree](../../tag/tree/README.md)]
4748
[[Depth-First Search](../../tag/depth-first-search/README.md)]
48-
[[Dynamic Programming](../../tag/dynamic-programming/README.md)]
4949
[[Binary Tree](../../tag/binary-tree/README.md)]
5050

5151
### Similar Questions
5252
1. [Path Sum](../path-sum) (Easy)
5353
1. [Sum Root to Leaf Numbers](../sum-root-to-leaf-numbers) (Medium)
5454
1. [Path Sum IV](../path-sum-iv) (Medium)
5555
1. [Longest Univalue Path](../longest-univalue-path) (Medium)
56+
1. [Time Needed to Inform All Employees](../time-needed-to-inform-all-employees) (Medium)

Diff for: problems/building-boxes/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ These boxes are placed in the corner of the room, where the corner is on the bac
6161
</ul>
6262

6363
### Related Topics
64-
[[Greedy](../../tag/greedy/README.md)]
6564
[[Math](../../tag/math/README.md)]
6665
[[Binary Search](../../tag/binary-search/README.md)]
66+
[[Greedy](../../tag/greedy/README.md)]
6767

6868
### Hints
6969
<details>

Diff for: problems/bulb-switcher-ii/README.md

+34-6
Original file line numberDiff line numberDiff line change
@@ -20,33 +20,60 @@
2020
<li><strong>Button 4:</strong> Flips the status of all the bulbs with a label <code>j = 3k + 1</code> where <code>k = 0, 1, 2, ...</code> (i.e., <code>1, 4, 7, 10, ...</code>).</li>
2121
</ul>
2222

23-
<p>You will press one of the four mentioned buttons exactly <code>presses</code> times.</p>
23+
<p>You must make <strong>exactly</strong> <code>presses</code> button presses in total. For each press, you may pick <strong>any</strong> of the four buttons to press.</p>
2424

25-
<p>Given the two integers <code>n</code> and <code>presses</code>, return <em>the number of <strong>different statuses</strong> after pressing the four buttons <strong>exactly</strong> </em><code>presses</code><em> times</em>.</p>
25+
<p>Given the two integers <code>n</code> and <code>presses</code>, return <em>the number of <strong>different possible statuses</strong> after performing all </em><code>presses</code><em> button presses</em>.</p>
2626

2727
<p>&nbsp;</p>
2828
<p><strong>Example 1:</strong></p>
2929

3030
<pre>
3131
<strong>Input:</strong> n = 1, presses = 1
3232
<strong>Output:</strong> 2
33-
<strong>Explanation:</strong> Status can be: [on], [off].
33+
<strong>Explanation:</strong> Status can be:
34+
- [off] by pressing button 1
35+
- [on] by pressing button 2
3436
</pre>
3537

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

3840
<pre>
3941
<strong>Input:</strong> n = 2, presses = 1
4042
<strong>Output:</strong> 3
41-
<strong>Explanation:</strong> Status can be: [on, off], [off, on], [off, off].
43+
<strong>Explanation:</strong> Status can be:
44+
- [off, off] by pressing button 1
45+
- [on, off] by pressing button 2
46+
- [off, on] by pressing button 3
4247
</pre>
4348

4449
<p><strong>Example 3:</strong></p>
4550

4651
<pre>
4752
<strong>Input:</strong> n = 3, presses = 1
4853
<strong>Output:</strong> 4
49-
<strong>Explanation:</strong> Status can be: [off, on, off], [on, off, on], [off, off, off], [off, on, on].
54+
<strong>Explanation:</strong> Status can be:
55+
- [off, off, off] by pressing button 1
56+
- [off, on, off] by pressing button 2
57+
- [on, off, on] by pressing button 3
58+
- [off, on, on] by pressing button 4
59+
</pre>
60+
61+
<p><strong>Example 4:</strong></p>
62+
63+
<pre>
64+
<strong>Input:</strong> n = 1, presses = 0
65+
<strong>Output:</strong> 1
66+
<strong>Explanation:</strong> Status can only be [on] since you cannot press any of the buttons.
67+
</pre>
68+
69+
<p><strong>Example 5:</strong></p>
70+
71+
<pre>
72+
<strong>Input:</strong> n = 1, presses = 2
73+
<strong>Output:</strong> 2
74+
<strong>Explanation:</strong> Status can be:
75+
- [off] by pressing button 1 then button 1 again
76+
- [on] by pressing button 1 then button 2
5077
</pre>
5178

5279
<p>&nbsp;</p>
@@ -58,10 +85,11 @@
5885
</ul>
5986

6087
### Related Topics
88+
[[Math](../../tag/math/README.md)]
6189
[[Bit Manipulation](../../tag/bit-manipulation/README.md)]
6290
[[Depth-First Search](../../tag/depth-first-search/README.md)]
6391
[[Breadth-First Search](../../tag/breadth-first-search/README.md)]
64-
[[Math](../../tag/math/README.md)]
6592

6693
### Similar Questions
6794
1. [Bulb Switcher](../bulb-switcher) (Medium)
95+
1. [Bulb Switcher III](../bulb-switcher-iii) (Medium)

Diff for: problems/can-make-arithmetic-progression-from-sequence/README.md

-3
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,6 @@
4444
[[Array](../../tag/array/README.md)]
4545
[[Sorting](../../tag/sorting/README.md)]
4646

47-
### Similar Questions
48-
1. [Arithmetic Subarrays](../arithmetic-subarrays) (Medium)
49-
5047
### Hints
5148
<details>
5249
<summary>Hint 1</summary>

0 commit comments

Comments
 (0)