Skip to content

Commit 6ccc864

Browse files
author
Shuo
authored
Merge pull request #811 from openset/develop
A: new
2 parents b347ed9 + 90cf398 commit 6ccc864

File tree

51 files changed

+1059
-452
lines changed

Some content is hidden

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

51 files changed

+1059
-452
lines changed

README.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ LeetCode Problems' Solutions
7070

7171
| # | Title | Solution | Difficulty |
7272
| :-: | - | - | :-: |
73+
| <span id="1569">1569</span> | [Number of Ways to Reorder Array to Get Same BST](https://leetcode.com/problems/number-of-ways-to-reorder-array-to-get-same-bst "将子数组重新排序得到同一个二叉查找树的方案数") | [Go](problems/number-of-ways-to-reorder-array-to-get-same-bst) | Hard |
74+
| <span id="1568">1568</span> | [Minimum Number of Days to Disconnect Island](https://leetcode.com/problems/minimum-number-of-days-to-disconnect-island "使陆地分离的最少天数") | [Go](problems/minimum-number-of-days-to-disconnect-island) | Hard |
75+
| <span id="1567">1567</span> | [Maximum Length of Subarray With Positive Product](https://leetcode.com/problems/maximum-length-of-subarray-with-positive-product "乘积为正数的最长子数组长度") | [Go](problems/maximum-length-of-subarray-with-positive-product) | Medium |
76+
| <span id="1566">1566</span> | [Detect Pattern of Length M Repeated K or More Times](https://leetcode.com/problems/detect-pattern-of-length-m-repeated-k-or-more-times "重复至少 K 次且长度为 M 的模式") | [Go](problems/detect-pattern-of-length-m-repeated-k-or-more-times) | Easy |
77+
| <span id="1565">1565</span> | [Unique Orders and Customers Per Month](https://leetcode.com/problems/unique-orders-and-customers-per-month) 🔒 | [MySQL](problems/unique-orders-and-customers-per-month) | Easy |
78+
| <span id="1564">1564</span> | [Put Boxes Into the Warehouse I](https://leetcode.com/problems/put-boxes-into-the-warehouse-i) 🔒 | [Go](problems/put-boxes-into-the-warehouse-i) | Medium |
7379
| <span id="1563">1563</span> | [Stone Game V](https://leetcode.com/problems/stone-game-v "石子游戏 V") | [Go](problems/stone-game-v) | Hard |
7480
| <span id="1562">1562</span> | [Find Latest Group of Size M](https://leetcode.com/problems/find-latest-group-of-size-m "查找大小为 M 的最新分组") | [Go](problems/find-latest-group-of-size-m) | Medium |
7581
| <span id="1561">1561</span> | [Maximum Number of Coins You Can Get](https://leetcode.com/problems/maximum-number-of-coins-you-can-get "你可以获得的最大硬币数目") | [Go](problems/maximum-number-of-coins-you-can-get) | Medium |
@@ -78,8 +84,8 @@ LeetCode Problems' Solutions
7884
| <span id="1558">1558</span> | [Minimum Numbers of Function Calls to Make Target Array](https://leetcode.com/problems/minimum-numbers-of-function-calls-to-make-target-array "得到目标数组的最少函数调用次数") | [Go](problems/minimum-numbers-of-function-calls-to-make-target-array) | Medium |
7985
| <span id="1557">1557</span> | [Minimum Number of Vertices to Reach All Nodes](https://leetcode.com/problems/minimum-number-of-vertices-to-reach-all-nodes "可以到达所有点的最少点数目") | [Go](problems/minimum-number-of-vertices-to-reach-all-nodes) | Medium |
8086
| <span id="1556">1556</span> | [Thousand Separator](https://leetcode.com/problems/thousand-separator "千位分隔数") | [Go](problems/thousand-separator) | Easy |
81-
| <span id="1555">1555</span> | [Bank Account Summary](https://leetcode.com/problems/bank-account-summary) 🔒 | [MySQL](problems/bank-account-summary) | Medium |
82-
| <span id="1554">1554</span> | [Strings Differ by One Character](https://leetcode.com/problems/strings-differ-by-one-character) 🔒 | [Go](problems/strings-differ-by-one-character) | Medium |
87+
| <span id="1555">1555</span> | [Bank Account Summary](https://leetcode.com/problems/bank-account-summary "银行账户概要") 🔒 | [MySQL](problems/bank-account-summary) | Medium |
88+
| <span id="1554">1554</span> | [Strings Differ by One Character](https://leetcode.com/problems/strings-differ-by-one-character "只有一个不同字符的字符串") 🔒 | [Go](problems/strings-differ-by-one-character) | Medium |
8389
| <span id="1553">1553</span> | [Minimum Number of Days to Eat N Oranges](https://leetcode.com/problems/minimum-number-of-days-to-eat-n-oranges "吃掉 N 个橘子的最少天数") | [Go](problems/minimum-number-of-days-to-eat-n-oranges) | Hard |
8490
| <span id="1552">1552</span> | [Magnetic Force Between Two Balls](https://leetcode.com/problems/magnetic-force-between-two-balls "两球之间的磁力") | [Go](problems/magnetic-force-between-two-balls) | Medium |
8591
| <span id="1551">1551</span> | [Minimum Operations to Make Array Equal](https://leetcode.com/problems/minimum-operations-to-make-array-equal "使数组中所有元素相等的最小操作数") | [Go](problems/minimum-operations-to-make-array-equal) | Medium |
@@ -101,17 +107,17 @@ LeetCode Problems' Solutions
101107
| <span id="1535">1535</span> | [Find the Winner of an Array Game](https://leetcode.com/problems/find-the-winner-of-an-array-game "找出数组游戏的赢家") | [Go](problems/find-the-winner-of-an-array-game) | Medium |
102108
| <span id="1534">1534</span> | [Count Good Triplets](https://leetcode.com/problems/count-good-triplets "统计好三元组") | [Go](problems/count-good-triplets) | Easy |
103109
| <span id="1533">1533</span> | [Find the Index of the Large Integer](https://leetcode.com/problems/find-the-index-of-the-large-integer) 🔒 | [Go](problems/find-the-index-of-the-large-integer) | Medium |
104-
| <span id="1532">1532</span> | [The Most Recent Three Orders](https://leetcode.com/problems/the-most-recent-three-orders) 🔒 | [MySQL](problems/the-most-recent-three-orders) | Medium |
110+
| <span id="1532">1532</span> | [The Most Recent Three Orders](https://leetcode.com/problems/the-most-recent-three-orders "最近的三笔订单") 🔒 | [MySQL](problems/the-most-recent-three-orders) | Medium |
105111
| <span id="1531">1531</span> | [String Compression II](https://leetcode.com/problems/string-compression-ii "压缩字符串 II") | [Go](problems/string-compression-ii) | Hard |
106112
| <span id="1530">1530</span> | [Number of Good Leaf Nodes Pairs](https://leetcode.com/problems/number-of-good-leaf-nodes-pairs "好叶子节点对的数量") | [Go](problems/number-of-good-leaf-nodes-pairs) | Medium |
107113
| <span id="1529">1529</span> | [Bulb Switcher IV](https://leetcode.com/problems/bulb-switcher-iv "灯泡开关 IV") | [Go](problems/bulb-switcher-iv) | Medium |
108114
| <span id="1528">1528</span> | [Shuffle String](https://leetcode.com/problems/shuffle-string "重新排列字符串") | [Go](problems/shuffle-string) | Easy |
109-
| <span id="1527">1527</span> | [Patients With a Condition](https://leetcode.com/problems/patients-with-a-condition) 🔒 | [MySQL](problems/patients-with-a-condition) | Easy |
115+
| <span id="1527">1527</span> | [Patients With a Condition](https://leetcode.com/problems/patients-with-a-condition "患某种疾病的患者") 🔒 | [MySQL](problems/patients-with-a-condition) | Easy |
110116
| <span id="1526">1526</span> | [Minimum Number of Increments on Subarrays to Form a Target Array](https://leetcode.com/problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array "形成目标数组的子数组最少增加次数") | [Go](problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array) | Hard |
111117
| <span id="1525">1525</span> | [Number of Good Ways to Split a String](https://leetcode.com/problems/number-of-good-ways-to-split-a-string "字符串的好分割数目") | [Go](problems/number-of-good-ways-to-split-a-string) | Medium |
112118
| <span id="1524">1524</span> | [Number of Sub-arrays With Odd Sum](https://leetcode.com/problems/number-of-sub-arrays-with-odd-sum "和为奇数的子数组数目") | [Go](problems/number-of-sub-arrays-with-odd-sum) | Medium |
113119
| <span id="1523">1523</span> | [Count Odd Numbers in an Interval Range](https://leetcode.com/problems/count-odd-numbers-in-an-interval-range "在区间范围内统计奇数数目") | [Go](problems/count-odd-numbers-in-an-interval-range) | Easy |
114-
| <span id="1522">1522</span> | [Diameter of N-Ary Tree](https://leetcode.com/problems/diameter-of-n-ary-tree) 🔒 | [Go](problems/diameter-of-n-ary-tree) | Medium |
120+
| <span id="1522">1522</span> | [Diameter of N-Ary Tree](https://leetcode.com/problems/diameter-of-n-ary-tree "N 叉树的直径") 🔒 | [Go](problems/diameter-of-n-ary-tree) | Medium |
115121
| <span id="1521">1521</span> | [Find a Value of a Mysterious Function Closest to Target](https://leetcode.com/problems/find-a-value-of-a-mysterious-function-closest-to-target "找到最接近目标值的函数值") | [Go](problems/find-a-value-of-a-mysterious-function-closest-to-target) | Hard |
116122
| <span id="1520">1520</span> | [Maximum Number of Non-Overlapping Substrings](https://leetcode.com/problems/maximum-number-of-non-overlapping-substrings "最多的不重叠子字符串") | [Go](problems/maximum-number-of-non-overlapping-substrings) | Hard |
117123
| <span id="1519">1519</span> | [Number of Nodes in the Sub-Tree With the Same Label](https://leetcode.com/problems/number-of-nodes-in-the-sub-tree-with-the-same-label "子树中标签相同的节点数") | [Go](problems/number-of-nodes-in-the-sub-tree-with-the-same-label) | Medium |

problems/bank-account-summary/README.md

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

1010
[Next >](../thousand-separator "Thousand Separator")
1111

12-
## [1555. Bank Account Summary (Medium)](https://leetcode.com/problems/bank-account-summary "")
12+
## [1555. Bank Account Summary (Medium)](https://leetcode.com/problems/bank-account-summary "银行账户概要")
1313

1414

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
Create table If Not Exists Users (user_id int, user_name varchar(20), credit int)
22
;
3-
Create table If Not Exists Transaction (trans_id int, paid_by int, paid_to int, amount int, transacted_on date);
3+
Create table If Not Exists Transactions (trans_id int, paid_by int, paid_to int, amount int, transacted_on date);
44
Truncate table Users;
55
insert into Users (user_id, user_name, credit) values ('1', 'Moustafa', '100');
66
insert into Users (user_id, user_name, credit) values ('2', 'Jonathan', '200');
77
insert into Users (user_id, user_name, credit) values ('3', 'Winston', '10000');
88
insert into Users (user_id, user_name, credit) values ('4', 'Luis', '800');
9-
Truncate table Transaction;
10-
insert into Transaction (trans_id, paid_by, paid_to, amount, transacted_on) values ('1', '1', '3', '400', '2020-08-01');
11-
insert into Transaction (trans_id, paid_by, paid_to, amount, transacted_on) values ('2', '3', '2', '500', '2020-08-02');
12-
insert into Transaction (trans_id, paid_by, paid_to, amount, transacted_on) values ('3', '2', '1', '200', '2020-08-03');
9+
Truncate table Transactions;
10+
insert into Transactions (trans_id, paid_by, paid_to, amount, transacted_on) values ('1', '1', '3', '400', '2020-08-01');
11+
insert into Transactions (trans_id, paid_by, paid_to, amount, transacted_on) values ('2', '3', '2', '500', '2020-08-02');
12+
insert into Transactions (trans_id, paid_by, paid_to, amount, transacted_on) values ('3', '2', '1', '200', '2020-08-03');

problems/binary-tree-inorder-traversal/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
### Similar Questions
3636
1. [Validate Binary Search Tree](../validate-binary-search-tree) (Medium)
3737
1. [Binary Tree Preorder Traversal](../binary-tree-preorder-traversal) (Medium)
38-
1. [Binary Tree Postorder Traversal](../binary-tree-postorder-traversal) (Hard)
38+
1. [Binary Tree Postorder Traversal](../binary-tree-postorder-traversal) (Medium)
3939
1. [Binary Search Tree Iterator](../binary-search-tree-iterator) (Medium)
4040
1. [Kth Smallest Element in a BST](../kth-smallest-element-in-a-bst) (Medium)
4141
1. [Closest Binary Search Tree Value II](../closest-binary-search-tree-value-ii) (Hard)

problems/binary-tree-postorder-traversal/README.md

Lines changed: 43 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,55 @@
99

1010
[Next >](../lru-cache "LRU Cache")
1111

12-
## [145. Binary Tree Postorder Traversal (Hard)](https://leetcode.com/problems/binary-tree-postorder-traversal "二叉树的后序遍历")
12+
## [145. Binary Tree Postorder Traversal (Medium)](https://leetcode.com/problems/binary-tree-postorder-traversal "二叉树的后序遍历")
1313

14-
<p>Given a binary tree, return the <em>postorder</em> traversal of its nodes&#39; values.</p>
14+
<p>Given the <code>root</code> of a&nbsp;binary tree, return the <em>postorder</em> traversal of its nodes&#39; values.</p>
1515

16-
<p><strong>Example:</strong></p>
16+
<p><strong>Follow up:</strong> Recursive solution is trivial, could you do it iteratively?</p>
1717

18+
<p>&nbsp;</p>
19+
<p><strong>Example 1:</strong></p>
20+
<img alt="" src="https://assets.leetcode.com/uploads/2020/08/28/pre1.jpg" style="width: 202px; height: 317px;" />
1821
<pre>
19-
<strong>Input:</strong>&nbsp;<code>[1,null,2,3]</code>
20-
1
21-
\
22-
2
23-
/
24-
3
25-
26-
<strong>Output:</strong>&nbsp;<code>[3,2,1]</code>
22+
<strong>Input:</strong> root = [1,null,2,3]
23+
<strong>Output:</strong> [3,2,1]
2724
</pre>
2825

29-
<p><strong>Follow up:</strong> Recursive solution is trivial, could you do it iteratively?</p>
26+
<p><strong>Example 2:</strong></p>
27+
28+
<pre>
29+
<strong>Input:</strong> root = []
30+
<strong>Output:</strong> []
31+
</pre>
32+
33+
<p><strong>Example 3:</strong></p>
34+
35+
<pre>
36+
<strong>Input:</strong> root = [1]
37+
<strong>Output:</strong> [1]
38+
</pre>
39+
40+
<p><strong>Example 4:</strong></p>
41+
<img alt="" src="https://assets.leetcode.com/uploads/2020/08/28/pre3.jpg" style="width: 202px; height: 197px;" />
42+
<pre>
43+
<strong>Input:</strong> root = [1,2]
44+
<strong>Output:</strong> [2,1]
45+
</pre>
46+
47+
<p><strong>Example 5:</strong></p>
48+
<img alt="" src="https://assets.leetcode.com/uploads/2020/08/28/pre2.jpg" style="width: 202px; height: 197px;" />
49+
<pre>
50+
<strong>Input:</strong> root = [1,null,2]
51+
<strong>Output:</strong> [2,1]
52+
</pre>
53+
54+
<p>&nbsp;</p>
55+
<p><strong>Constraints:</strong></p>
56+
57+
<ul>
58+
<li>The number of the nodes in the tree is in the range <code>[0, 100]</code>.</li>
59+
<li><code>-100 &lt;= Node.val &lt;= 100</code></li>
60+
</ul>
3061

3162
### Related Topics
3263
[[Stack](../../tag/stack/README.md)]

problems/check-if-word-is-valid-after-substitutions/README.md

Lines changed: 23 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -11,71 +11,60 @@
1111

1212
## [1003. Check If Word Is Valid After Substitutions (Medium)](https://leetcode.com/problems/check-if-word-is-valid-after-substitutions "检查替换后的词是否有效")
1313

14-
<p>We are given that the string <code>&quot;abc&quot;</code> is valid.</p>
14+
<p>We can say that a string is valid if it follows one of the three following cases:</p>
1515

16-
<p>From any valid string <code>V</code>, we may split&nbsp;<code>V</code> into two pieces <code>X</code> and <code>Y</code> such that <code>X + Y</code> (<code>X</code> concatenated with <code>Y</code>) is equal to <code>V</code>.&nbsp; (<code>X</code> or <code>Y</code> may be empty.)&nbsp; Then, <code>X + &quot;abc&quot; + Y</code> is also valid.</p>
16+
<ul>
17+
<li>An empty string <code>&quot;&quot;</code> is valid.</li>
18+
<li>The string <code>&quot;abc&quot;</code> is also valid.</li>
19+
<li>Any string in the form <code>&quot;a&quot; + str + &quot;bc&quot;</code>, <code>&quot;ab&quot; + str + &quot;c&quot;</code>, <code>str + &quot;abc&quot;</code> or <code>&quot;abc&quot; + str</code> where <code>str</code> is a valid string is also considered a valid string.</li>
20+
</ul>
1721

18-
<p>If for example <code>S = &quot;abc&quot;</code>, then examples of valid strings are: <code>&quot;abc&quot;, &quot;aabcbc&quot;, &quot;abcabc&quot;, &quot;abcabcababcc&quot;</code>.&nbsp; Examples of <strong>invalid</strong>&nbsp;strings are: <code>&quot;abccba&quot;</code>, <code>&quot;ab&quot;</code>, <code>&quot;cababc&quot;</code>, <code>&quot;bac&quot;</code>.</p>
22+
<p>For example, <code>&quot;&quot;</code>, <code>&quot;abc&quot;</code>,&nbsp;<code>&quot;aabcbc&quot;</code>,&nbsp;<code>&quot;abcabc&quot;</code> and&nbsp;<code>&quot;abcabcababcc&quot;</code>&nbsp;are all <strong>valid</strong> strings, while&nbsp;<code>&quot;abccba&quot;</code>,&nbsp;<code>&quot;ab&quot;</code>, <code>&quot;cababc&quot;</code> and&nbsp;<code>&quot;bac&quot;</code>&nbsp;are <strong>not valid</strong> strings.</p>
1923

20-
<p>Return <code>true</code> if and only if the given string&nbsp;<code>S</code>&nbsp;is valid.</p>
24+
<p>Given a string <code>s</code>, return <code>true</code> if it is a valid string, otherwise, return <code>false</code>.</p>
2125

2226
<p>&nbsp;</p>
23-
2427
<p><strong>Example 1:</strong></p>
2528

2629
<pre>
27-
<strong>Input: </strong><span id="example-input-1-1">&quot;aabcbc&quot;</span>
28-
<strong>Output: </strong><span id="example-output-1">true</span>
30+
<strong>Input:</strong> s = &quot;aabcbc&quot;
31+
<strong>Output:</strong> true
2932
<strong>Explanation: </strong>
3033
We start with the valid string &quot;abc&quot;.
3134
Then we can insert another &quot;abc&quot; between &quot;a&quot; and &quot;bc&quot;, resulting in &quot;a&quot; + &quot;abc&quot; + &quot;bc&quot; which is &quot;aabcbc&quot;.
3235
</pre>
3336

34-
<div>
3537
<p><strong>Example 2:</strong></p>
3638

3739
<pre>
38-
<strong>Input: </strong><span id="example-input-2-1">&quot;abcabcababcc&quot;</span>
39-
<strong>Output: </strong><span id="example-output-2">true</span>
40+
<strong>Input:</strong> s = &quot;abcabcababcc&quot;
41+
<strong>Output:</strong> true
4042
<strong>Explanation: </strong>
4143
&quot;abcabcabc&quot; is valid after consecutive insertings of &quot;abc&quot;.
4244
Then we can insert &quot;abc&quot; before the last letter, resulting in &quot;abcabcab&quot; + &quot;abc&quot; + &quot;c&quot; which is &quot;abcabcababcc&quot;.
4345
</pre>
4446

45-
<div>
4647
<p><strong>Example 3:</strong></p>
4748

4849
<pre>
49-
<strong>Input: </strong><span id="example-input-3-1">&quot;abccba&quot;</span>
50-
<strong>Output: </strong><span id="example-output-3">false</span>
50+
<strong>Input:</strong> s = &quot;abccba&quot;
51+
<strong>Output:</strong> false
5152
</pre>
5253

53-
<div>
5454
<p><strong>Example 4:</strong></p>
5555

5656
<pre>
57-
<strong>Input: </strong><span id="example-input-4-1">&quot;cababc&quot;</span>
58-
<strong>Output: </strong><span id="example-output-4">false</span></pre>
57+
<strong>Input:</strong> s = &quot;cababc&quot;
58+
<strong>Output:</strong> false
59+
</pre>
5960

6061
<p>&nbsp;</p>
61-
</div>
62-
</div>
63-
</div>
64-
65-
<p><strong>Note:</strong></p>
66-
67-
<ol>
68-
<li><code>1 &lt;= S.length &lt;= 20000</code></li>
69-
<li><code>S[i]</code> is <code>&#39;a&#39;</code>, <code>&#39;b&#39;</code>, or <code>&#39;c&#39;</code></li>
70-
</ol>
71-
72-
<div>
73-
<div>
74-
<div>
75-
<div>&nbsp;</div>
76-
</div>
77-
</div>
78-
</div>
62+
<p><strong>Constraints:</strong></p>
63+
64+
<ul>
65+
<li><code>1 &lt;= s.length &lt;= 2 * 10<sup>4</sup></code></li>
66+
<li><code>s[i]</code> is <code>&#39;a&#39;</code>, <code>&#39;b&#39;</code>, or <code>&#39;c&#39;</code></li>
67+
</ul>
7968

8069
### Related Topics
8170
[[Stack](../../tag/stack/README.md)]

0 commit comments

Comments
 (0)