Skip to content

Commit b259efe

Browse files
author
Shuo
authored
Merge pull request #789 from openset/develop
A: new
2 parents ef2bad3 + d2f3c63 commit b259efe

File tree

31 files changed

+763
-184
lines changed

31 files changed

+763
-184
lines changed

README.md

+11-2
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,15 @@ LeetCode Problems' Solutions
6262

6363
| # | Title | Solution | Difficulty |
6464
| :-: | - | - | :-: |
65+
| <span id="1453">1453</span> | [Maximum Number of Darts Inside of a Circular Dartboard](https://leetcode.com/problems/maximum-number-of-darts-inside-of-a-circular-dartboard "圆形靶内的最大飞镖数量") | [Go](problems/maximum-number-of-darts-inside-of-a-circular-dartboard) | Hard |
66+
| <span id="1452">1452</span> | [People Whose List of Favorite Companies Is Not a Subset of Another List](https://leetcode.com/problems/people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list "收藏清单") | [Go](problems/people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list) | Medium |
67+
| <span id="1451">1451</span> | [Rearrange Words in a Sentence](https://leetcode.com/problems/rearrange-words-in-a-sentence "重新排列句子中的单词") | [Go](problems/rearrange-words-in-a-sentence) | Medium |
68+
| <span id="1450">1450</span> | [Number of Students Doing Homework at a Given Time](https://leetcode.com/problems/number-of-students-doing-homework-at-a-given-time "在既定时间做作业的学生人数") | [Go](problems/number-of-students-doing-homework-at-a-given-time) | Easy |
69+
| <span id="1449">1449</span> | [Form Largest Integer With Digits That Add up to Target](https://leetcode.com/problems/form-largest-integer-with-digits-that-add-up-to-target "数位成本和为目标值的最大数字") | [Go](problems/form-largest-integer-with-digits-that-add-up-to-target) | Hard |
70+
| <span id="1448">1448</span> | [Count Good Nodes in Binary Tree](https://leetcode.com/problems/count-good-nodes-in-binary-tree "统计二叉树中好节点的数目") | [Go](problems/count-good-nodes-in-binary-tree) | Medium |
71+
| <span id="1447">1447</span> | [Simplified Fractions](https://leetcode.com/problems/simplified-fractions "最简分数") | [Go](problems/simplified-fractions) | Medium |
72+
| <span id="1446">1446</span> | [Consecutive Characters](https://leetcode.com/problems/consecutive-characters "连续字符") | [Go](problems/consecutive-characters) | Easy |
73+
| <span id="1445">1445</span> | [Apples & Oranges](https://leetcode.com/problems/apples-oranges) 🔒 | [MySQL](problems/apples-oranges) | Medium |
6574
| <span id="1444">1444</span> | [Number of Ways of Cutting a Pizza](https://leetcode.com/problems/number-of-ways-of-cutting-a-pizza "切披萨的方案数") | [Go](problems/number-of-ways-of-cutting-a-pizza) | Hard |
6675
| <span id="1443">1443</span> | [Minimum Time to Collect All Apples in a Tree](https://leetcode.com/problems/minimum-time-to-collect-all-apples-in-a-tree "收集树上所有苹果的最少时间") | [Go](problems/minimum-time-to-collect-all-apples-in-a-tree) | Medium |
6776
| <span id="1442">1442</span> | [Count Triplets That Can Form Two Arrays of Equal XOR](https://leetcode.com/problems/count-triplets-that-can-form-two-arrays-of-equal-xor "形成两个异或相等数组的三元组数目") | [Go](problems/count-triplets-that-can-form-two-arrays-of-equal-xor) | Medium |
@@ -85,7 +94,7 @@ LeetCode Problems' Solutions
8594
| <span id="1424">1424</span> | [Diagonal Traverse II](https://leetcode.com/problems/diagonal-traverse-ii "对角线遍历 II") | [Go](problems/diagonal-traverse-ii) | Medium |
8695
| <span id="1423">1423</span> | [Maximum Points You Can Obtain from Cards](https://leetcode.com/problems/maximum-points-you-can-obtain-from-cards "可获得的最大点数") | [Go](problems/maximum-points-you-can-obtain-from-cards) | Medium |
8796
| <span id="1422">1422</span> | [Maximum Score After Splitting a String](https://leetcode.com/problems/maximum-score-after-splitting-a-string "分割字符串的最大得分") | [Go](problems/maximum-score-after-splitting-a-string) | Easy |
88-
| <span id="1421">1421</span> | [NPV Queries](https://leetcode.com/problems/npv-queries) 🔒 | [MySQL](problems/npv-queries) | Medium |
97+
| <span id="1421">1421</span> | [NPV Queries](https://leetcode.com/problems/npv-queries "净现值查询") 🔒 | [MySQL](problems/npv-queries) | Medium |
8998
| <span id="1420">1420</span> | [Build Array Where You Can Find The Maximum Exactly K Comparisons](https://leetcode.com/problems/build-array-where-you-can-find-the-maximum-exactly-k-comparisons "生成数组") | [Go](problems/build-array-where-you-can-find-the-maximum-exactly-k-comparisons) | Hard |
9099
| <span id="1419">1419</span> | [Minimum Number of Frogs Croaking](https://leetcode.com/problems/minimum-number-of-frogs-croaking "数青蛙") | [Go](problems/minimum-number-of-frogs-croaking) | Medium |
91100
| <span id="1418">1418</span> | [Display Table of Food Orders in a Restaurant](https://leetcode.com/problems/display-table-of-food-orders-in-a-restaurant "点菜展示表") | [Go](problems/display-table-of-food-orders-in-a-restaurant) | Medium |
@@ -94,7 +103,7 @@ LeetCode Problems' Solutions
94103
| <span id="1415">1415</span> | [The k-th Lexicographical String of All Happy Strings of Length n](https://leetcode.com/problems/the-k-th-lexicographical-string-of-all-happy-strings-of-length-n "长度为 n 的开心字符串中字典序第 k 小的字符串") | [Go](problems/the-k-th-lexicographical-string-of-all-happy-strings-of-length-n) | Medium |
95104
| <span id="1414">1414</span> | [Find the Minimum Number of Fibonacci Numbers Whose Sum Is K](https://leetcode.com/problems/find-the-minimum-number-of-fibonacci-numbers-whose-sum-is-k "和为 K 的最少斐波那契数字数目") | [Go](problems/find-the-minimum-number-of-fibonacci-numbers-whose-sum-is-k) | Medium |
96105
| <span id="1413">1413</span> | [Minimum Value to Get Positive Step by Step Sum](https://leetcode.com/problems/minimum-value-to-get-positive-step-by-step-sum "逐步求和得到正数的最小值") | [Go](problems/minimum-value-to-get-positive-step-by-step-sum) | Easy |
97-
| <span id="1412">1412</span> | [Find the Quiet Students in All Exams](https://leetcode.com/problems/find-the-quiet-students-in-all-exams) 🔒 | [MySQL](problems/find-the-quiet-students-in-all-exams) | Hard |
106+
| <span id="1412">1412</span> | [Find the Quiet Students in All Exams](https://leetcode.com/problems/find-the-quiet-students-in-all-exams "查找成绩处于中游的的学生") 🔒 | [MySQL](problems/find-the-quiet-students-in-all-exams) | Hard |
98107
| <span id="1411">1411</span> | [Number of Ways to Paint N × 3 Grid](https://leetcode.com/problems/number-of-ways-to-paint-n-3-grid "给 N x 3 网格图涂色的方案数") | [Go](problems/number-of-ways-to-paint-n-3-grid) | Hard |
99108
| <span id="1410">1410</span> | [HTML Entity Parser](https://leetcode.com/problems/html-entity-parser "HTML 实体解析器") | [Go](problems/html-entity-parser) | Medium |
100109
| <span id="1409">1409</span> | [Queries on a Permutation With Key](https://leetcode.com/problems/queries-on-a-permutation-with-key "查询带键的排列") | [Go](problems/queries-on-a-permutation-with-key) | Medium |

problems/apples-oranges/README.md

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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](../number-of-ways-of-cutting-a-pizza "Number of Ways of Cutting a Pizza")
9+
                
10+
[Next >](../consecutive-characters "Consecutive Characters")
11+
12+
## [1445. Apples & Oranges (Medium)](https://leetcode.com/problems/apples-oranges "")
13+
14+
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Create table If Not Exists Sales (sale_date date, fruit ENUM('apples', 'oranges'), sold_num int);
2+
Truncate table Sales;
3+
insert into Sales (sale_date, fruit, sold_num) values ('2020-05-01', 'apples', '10');
4+
insert into Sales (sale_date, fruit, sold_num) values ('2020-05-01', 'oranges', '8');
5+
insert into Sales (sale_date, fruit, sold_num) values ('2020-05-02', 'apples', '15');
6+
insert into Sales (sale_date, fruit, sold_num) values ('2020-05-02', 'oranges', '15');
7+
insert into Sales (sale_date, fruit, sold_num) values ('2020-05-03', 'apples', '20');
8+
insert into Sales (sale_date, fruit, sold_num) values ('2020-05-03', 'oranges', '0');
9+
insert into Sales (sale_date, fruit, sold_num) values ('2020-05-04', 'apples', '15');
10+
insert into Sales (sale_date, fruit, sold_num) values ('2020-05-04', 'oranges', '16');
+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
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](../apples-oranges "Apples & Oranges")
9+
                
10+
[Next >](../simplified-fractions "Simplified Fractions")
11+
12+
## [1446. Consecutive Characters (Easy)](https://leetcode.com/problems/consecutive-characters "连续字符")
13+
14+
<p>Given a string <code>s</code>, the power of the string is the maximum length of a non-empty substring that&nbsp;contains only one unique character.</p>
15+
16+
<p>Return <em>the power</em>&nbsp;of the string.</p>
17+
18+
<p>&nbsp;</p>
19+
<p><strong>Example 1:</strong></p>
20+
21+
<pre>
22+
<strong>Input:</strong> s = &quot;leetcode&quot;
23+
<strong>Output:</strong> 2
24+
<strong>Explanation:</strong> The substring &quot;ee&quot; is of length 2 with the character &#39;e&#39; only.
25+
</pre>
26+
27+
<p><strong>Example 2:</strong></p>
28+
29+
<pre>
30+
<strong>Input:</strong> s = &quot;abbcccddddeeeeedcba&quot;
31+
<strong>Output:</strong> 5
32+
<strong>Explanation:</strong> The substring &quot;eeeee&quot; is of length 5 with the character &#39;e&#39; only.
33+
</pre>
34+
35+
<p><strong>Example 3:</strong></p>
36+
37+
<pre>
38+
<strong>Input:</strong> s = &quot;triplepillooooow&quot;
39+
<strong>Output:</strong> 5
40+
</pre>
41+
42+
<p><strong>Example 4:</strong></p>
43+
44+
<pre>
45+
<strong>Input:</strong> s = &quot;hooraaaaaaaaaaay&quot;
46+
<strong>Output:</strong> 11
47+
</pre>
48+
49+
<p><strong>Example 5:</strong></p>
50+
51+
<pre>
52+
<strong>Input:</strong> s = &quot;tourist&quot;
53+
<strong>Output:</strong> 1
54+
</pre>
55+
56+
<p>&nbsp;</p>
57+
<p><strong>Constraints:</strong></p>
58+
59+
<ul>
60+
<li><code>1 &lt;= s.length &lt;= 500</code></li>
61+
<li><code>s</code> contains only lowercase English letters.</li>
62+
</ul>
63+
64+
### Related Topics
65+
[[String](../../tag/string/README.md)]
66+
67+
### Hints
68+
<details>
69+
<summary>Hint 1</summary>
70+
Keep an array power where power[i] is the maximum power of the i-th character.
71+
</details>
72+
73+
<details>
74+
<summary>Hint 2</summary>
75+
The answer is max(power[i]).
76+
</details>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
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](../simplified-fractions "Simplified Fractions")
9+
                
10+
[Next >](../form-largest-integer-with-digits-that-add-up-to-target "Form Largest Integer With Digits That Add up to Target")
11+
12+
## [1448. Count Good Nodes in Binary Tree (Medium)](https://leetcode.com/problems/count-good-nodes-in-binary-tree "统计二叉树中好节点的数目")
13+
14+
<p>Given a binary tree <code>root</code>, a node <em>X</em> in the tree is named&nbsp;<strong>good</strong> if in the path from root to <em>X</em> there are no nodes with a value <em>greater than</em> X.</p>
15+
16+
<p>Return the number of <strong>good</strong> nodes in the binary tree.</p>
17+
18+
<p>&nbsp;</p>
19+
<p><strong>Example 1:</strong></p>
20+
21+
<p><strong><img alt="" src="https://assets.leetcode.com/uploads/2020/04/02/test_sample_1.png" style="width: 263px; height: 156px;" /></strong></p>
22+
23+
<pre>
24+
<strong>Input:</strong> root = [3,1,4,3,null,1,5]
25+
<strong>Output:</strong> 4
26+
<strong>Explanation:</strong> Nodes in blue are <strong>good</strong>.
27+
Root Node (3) is always a good node.
28+
Node 4 -&gt; (3,4) is the maximum value in the path starting from the root.
29+
Node 5 -&gt; (3,4,5) is the maximum value in the path
30+
Node 3 -&gt; (3,1,3) is the maximum value in the path.</pre>
31+
32+
<p><strong>Example 2:</strong></p>
33+
34+
<p><strong><img alt="" src="https://assets.leetcode.com/uploads/2020/04/02/test_sample_2.png" style="width: 157px; height: 161px;" /></strong></p>
35+
36+
<pre>
37+
<strong>Input:</strong> root = [3,3,null,4,2]
38+
<strong>Output:</strong> 3
39+
<strong>Explanation:</strong> Node 2 -&gt; (3, 3, 2) is not good, because &quot;3&quot; is higher than it.</pre>
40+
41+
<p><strong>Example 3:</strong></p>
42+
43+
<pre>
44+
<strong>Input:</strong> root = [1]
45+
<strong>Output:</strong> 1
46+
<strong>Explanation:</strong> Root is considered as <strong>good</strong>.</pre>
47+
48+
<p>&nbsp;</p>
49+
<p><strong>Constraints:</strong></p>
50+
51+
<ul>
52+
<li>The number of nodes in the binary tree is in the range&nbsp;<code>[1, 10^5]</code>.</li>
53+
<li>Each node&#39;s value is between <code>[-10^4, 10^4]</code>.</li>
54+
</ul>
55+
56+
### Related Topics
57+
[[Tree](../../tag/tree/README.md)]
58+
[[Depth-first Search](../../tag/depth-first-search/README.md)]
59+
60+
### Hints
61+
<details>
62+
<summary>Hint 1</summary>
63+
Use DFS (Depth First Search) to traverse the tree, and constantly keep track of the current path maximum.
64+
</details>

problems/cousins-in-binary-tree/README.md

+6-12
Original file line numberDiff line numberDiff line change
@@ -45,24 +45,18 @@
4545

4646
<pre>
4747
<strong>Input: </strong>root = <span id="example-input-3-1">[1,2,3,null,4]</span>, x = 2, y = 3
48-
<strong>Output: </strong><span id="example-output-3">false</span></pre>
49-
50-
<p>&nbsp;</p>
48+
<strong>Output: </strong><span id="example-output-3">false</span>
49+
</pre>
5150
</div>
5251
</div>
5352

54-
<p><strong>Note:</strong></p>
53+
<p>&nbsp;</p>
54+
<p><strong>Constraints:</strong></p>
5555

56-
<ol>
56+
<ul>
5757
<li>The number of nodes in the tree will be between <code>2</code> and <code>100</code>.</li>
5858
<li>Each node has a unique integer value from <code>1</code> to <code>100</code>.</li>
59-
</ol>
60-
61-
<div>
62-
<div>
63-
<div>&nbsp;</div>
64-
</div>
65-
</div>
59+
</ul>
6660

6761
### Related Topics
6862
[[Tree](../../tag/tree/README.md)]

problems/find-the-quiet-students-in-all-exams/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99

1010
[Next >](../minimum-value-to-get-positive-step-by-step-sum "Minimum Value to Get Positive Step by Step Sum")
1111

12-
## [1412. Find the Quiet Students in All Exams (Hard)](https://leetcode.com/problems/find-the-quiet-students-in-all-exams "")
12+
## [1412. Find the Quiet Students in All Exams (Hard)](https://leetcode.com/problems/find-the-quiet-students-in-all-exams "查找成绩处于中游的的学生")
1313

1414

problems/find-the-town-judge/README.md

+19-46
Original file line numberDiff line numberDiff line change
@@ -26,60 +26,33 @@
2626
<p>If the town judge exists and can be identified, return the label of the town judge.&nbsp; Otherwise, return <code>-1</code>.</p>
2727

2828
<p>&nbsp;</p>
29-
3029
<p><strong>Example 1:</strong></p>
31-
32-
<pre>
33-
<strong>Input: </strong>N = <span id="example-input-1-1">2</span>, trust = <span id="example-input-1-2">[[1,2]]</span>
34-
<strong>Output: </strong><span id="example-output-1">2</span>
35-
</pre>
36-
37-
<div>
38-
<p><strong>Example 2:</strong></p>
39-
40-
<pre>
41-
<strong>Input: </strong>N = <span id="example-input-2-1">3</span>, trust = <span id="example-input-2-2">[[1,3],[2,3]]</span>
42-
<strong>Output: </strong><span id="example-output-2">3</span>
30+
<pre><strong>Input:</strong> N = 2, trust = [[1,2]]
31+
<strong>Output:</strong> 2
32+
</pre><p><strong>Example 2:</strong></p>
33+
<pre><strong>Input:</strong> N = 3, trust = [[1,3],[2,3]]
34+
<strong>Output:</strong> 3
35+
</pre><p><strong>Example 3:</strong></p>
36+
<pre><strong>Input:</strong> N = 3, trust = [[1,3],[2,3],[3,1]]
37+
<strong>Output:</strong> -1
38+
</pre><p><strong>Example 4:</strong></p>
39+
<pre><strong>Input:</strong> N = 3, trust = [[1,2],[2,3]]
40+
<strong>Output:</strong> -1
41+
</pre><p><strong>Example 5:</strong></p>
42+
<pre><strong>Input:</strong> N = 4, trust = [[1,3],[1,4],[2,3],[2,4],[4,3]]
43+
<strong>Output:</strong> 3
4344
</pre>
44-
45-
<div>
46-
<p><strong>Example 3:</strong></p>
47-
48-
<pre>
49-
<strong>Input: </strong>N = <span id="example-input-3-1">3</span>, trust = <span id="example-input-3-2">[[1,3],[2,3],[3,1]]</span>
50-
<strong>Output: </strong><span id="example-output-3">-1</span>
51-
</pre>
52-
53-
<div>
54-
<p><strong>Example 4:</strong></p>
55-
56-
<pre>
57-
<strong>Input: </strong>N = <span id="example-input-4-1">3</span>, trust = <span id="example-input-4-2">[[1,2],[2,3]]</span>
58-
<strong>Output: </strong><span id="example-output-4">-1</span>
59-
</pre>
60-
61-
<div>
62-
<p><strong>Example 5:</strong></p>
63-
64-
<pre>
65-
<strong>Input: </strong>N = <span id="example-input-5-1">4</span>, trust = <span id="example-input-5-2">[[1,3],[1,4],[2,3],[2,4],[4,3]]</span>
66-
<strong>Output: </strong><span id="example-output-5">3</span></pre>
67-
6845
<p>&nbsp;</p>
69-
</div>
70-
</div>
71-
</div>
72-
</div>
73-
74-
<p><strong>Note:</strong></p>
46+
<p><strong>Constraints:</strong></p>
7547

76-
<ol>
48+
<ul>
7749
<li><code>1 &lt;= N &lt;= 1000</code></li>
78-
<li><code>trust.length &lt;= 10000</code></li>
50+
<li><code>0 &lt;= trust.length &lt;= 10^4</code></li>
51+
<li><code>trust[i].length == 2</code></li>
7952
<li><code>trust[i]</code> are all different</li>
8053
<li><code>trust[i][0] != trust[i][1]</code></li>
8154
<li><code>1 &lt;= trust[i][0], trust[i][1] &lt;= N</code></li>
82-
</ol>
55+
</ul>
8356

8457
### Related Topics
8558
[[Graph](../../tag/graph/README.md)]

0 commit comments

Comments
 (0)