Skip to content

Commit 14db544

Browse files
author
Shuo
committed
A: new
1 parent 48ef8ff commit 14db544

File tree

41 files changed

+576
-141
lines changed

Some content is hidden

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

41 files changed

+576
-141
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ LeetCode Problems' Solutions
7070

7171
| # | Title | Solution | Difficulty |
7272
| :-: | - | - | :-: |
73+
| <span id="1628">1628</span> | [Design an Expression Tree With Evaluate Function](https://leetcode.com/problems/design-an-expression-tree-with-evaluate-function) 🔒 | [Go](problems/design-an-expression-tree-with-evaluate-function) | Medium |
74+
| <span id="1627">1627</span> | [Graph Connectivity With Threshold](https://leetcode.com/problems/graph-connectivity-with-threshold "带阈值的图连通性") | [Go](problems/graph-connectivity-with-threshold) | Hard |
75+
| <span id="1626">1626</span> | [Best Team With No Conflicts](https://leetcode.com/problems/best-team-with-no-conflicts "无矛盾的最佳球队") | [Go](problems/best-team-with-no-conflicts) | Medium |
76+
| <span id="1625">1625</span> | [Lexicographically Smallest String After Applying Operations](https://leetcode.com/problems/lexicographically-smallest-string-after-applying-operations "执行操作后字典序最小的字符串") | [Go](problems/lexicographically-smallest-string-after-applying-operations) | Medium |
77+
| <span id="1624">1624</span> | [Largest Substring Between Two Equal Characters](https://leetcode.com/problems/largest-substring-between-two-equal-characters "两个相同字符之间的最长子字符串") | [Go](problems/largest-substring-between-two-equal-characters) | Easy |
78+
| <span id="1623">1623</span> | [All Valid Triplets That Can Represent a Country](https://leetcode.com/problems/all-valid-triplets-that-can-represent-a-country) 🔒 | [MySQL](problems/all-valid-triplets-that-can-represent-a-country) | Easy |
7379
| <span id="1622">1622</span> | [Fancy Sequence](https://leetcode.com/problems/fancy-sequence "奇妙序列") | [Go](problems/fancy-sequence) | Hard |
7480
| <span id="1621">1621</span> | [Number of Sets of K Non-Overlapping Line Segments](https://leetcode.com/problems/number-of-sets-of-k-non-overlapping-line-segments "大小为 K 的不重叠线段的数目") | [Go](problems/number-of-sets-of-k-non-overlapping-line-segments) | Medium |
7581
| <span id="1620">1620</span> | [Coordinate With Maximum Network Quality](https://leetcode.com/problems/coordinate-with-maximum-network-quality "网络信号最好的坐标") | [Go](problems/coordinate-with-maximum-network-quality) | Medium |
@@ -111,7 +117,7 @@ LeetCode Problems' Solutions
111117
| <span id="1584">1584</span> | [Min Cost to Connect All Points](https://leetcode.com/problems/min-cost-to-connect-all-points "连接所有点的最小费用") | [Go](problems/min-cost-to-connect-all-points) | Medium |
112118
| <span id="1583">1583</span> | [Count Unhappy Friends](https://leetcode.com/problems/count-unhappy-friends "统计不开心的朋友") | [Go](problems/count-unhappy-friends) | Medium |
113119
| <span id="1582">1582</span> | [Special Positions in a Binary Matrix](https://leetcode.com/problems/special-positions-in-a-binary-matrix "二进制矩阵中的特殊位置") | [Go](problems/special-positions-in-a-binary-matrix) | Easy |
114-
| <span id="1581">1581</span> | [Customer Who Visited but Did Not Make Any Transactions](https://leetcode.com/problems/customer-who-visited-but-did-not-make-any-transactions "进店却未进行过交易的客户") 🔒 | [MySQL](problems/customer-who-visited-but-did-not-make-any-transactions) | Easy |
120+
| <span id="1581">1581</span> | [Customer Who Visited but Did Not Make Any Transactions](https://leetcode.com/problems/customer-who-visited-but-did-not-make-any-transactions "进店却未进行过交易的顾客") 🔒 | [MySQL](problems/customer-who-visited-but-did-not-make-any-transactions) | Easy |
115121
| <span id="1580">1580</span> | [Put Boxes Into the Warehouse II](https://leetcode.com/problems/put-boxes-into-the-warehouse-ii) 🔒 | [Go](problems/put-boxes-into-the-warehouse-ii) | Medium |
116122
| <span id="1579">1579</span> | [Remove Max Number of Edges to Keep Graph Fully Traversable](https://leetcode.com/problems/remove-max-number-of-edges-to-keep-graph-fully-traversable "保证图可完全遍历") | [Go](problems/remove-max-number-of-edges-to-keep-graph-fully-traversable) | Hard |
117123
| <span id="1578">1578</span> | [Minimum Deletion Cost to Avoid Repeating Letters](https://leetcode.com/problems/minimum-deletion-cost-to-avoid-repeating-letters "避免重复字母的最小删除成本") | [Go](problems/minimum-deletion-cost-to-avoid-repeating-letters) | Medium |
Lines changed: 14 additions & 0 deletions
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](../fancy-sequence "Fancy Sequence")
9+
                
10+
[Next >](../largest-substring-between-two-equal-characters "Largest Substring Between Two Equal Characters")
11+
12+
## [1623. All Valid Triplets That Can Represent a Country (Easy)](https://leetcode.com/problems/all-valid-triplets-that-can-represent-a-country "")
13+
14+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Create table If Not Exists SchoolA (student_id int, student_name varchar(20));
2+
Create table If Not Exists SchoolB (student_id int, student_name varchar(20));
3+
Create table If Not Exists SchoolC (student_id int, student_name varchar(20));
4+
Truncate table SchoolA;
5+
insert into SchoolA (student_id, student_name) values ('1', 'Alice');
6+
insert into SchoolA (student_id, student_name) values ('2', 'Bob');
7+
Truncate table SchoolB;
8+
insert into SchoolB (student_id, student_name) values ('3', 'Tom');
9+
Truncate table SchoolC;
10+
insert into SchoolC (student_id, student_name) values ('3', 'Tom');
11+
insert into SchoolC (student_id, student_name) values ('2', 'Jerry');
12+
insert into SchoolC (student_id, student_name) values ('10', 'Alice');

problems/bag-of-tokens/README.md

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -11,58 +11,56 @@
1111

1212
## [948. Bag of Tokens (Medium)](https://leetcode.com/problems/bag-of-tokens "令牌放置")
1313

14-
<p>You have an initial power <code>P</code>, an initial score of <code>0</code> points, and a bag of tokens.</p>
14+
<p>You have an initial <strong>power</strong> of <code>P</code>, an initial <strong>score</strong> of <code>0</code>, and a bag of <code>tokens</code> where <code>tokens[i]</code> is the value of the <code>i<sup>th</sup></code> token (0-indexed).</p>
1515

16-
<p>Each token can be used at most once, has a value <code>token[i]</code>, and has potentially two ways to use it.</p>
16+
<p>Your goal is to maximize your total <strong>score</strong> by potentially playing each token in one of two ways:</p>
1717

1818
<ul>
19-
<li>If we have at least <code>token[i]</code> power, we may play the token face up, losing <code>token[i]</code> power, and gaining <code>1</code> point.</li>
20-
<li>If we have at least <code>1</code> point, we may play the token face down, gaining <code>token[i]</code> power, and losing <code>1</code> point.</li>
19+
<li>If your current <strong>power</strong> is at least <code>tokens[i]</code>, you may play the <code>i<sup>th</sup></code> token face up, losing <code>tokens[i]</code> <strong>power</strong> and gaining <code>1</code> <strong>score</strong>.</li>
20+
<li>If your current <strong>score</strong> is at least <code>1</code>, you may play the <code>i<sup>th</sup></code> token face down, gaining <code>tokens[i]</code> <strong>power</strong> and losing <code>1</code> <strong>score</strong>.</li>
2121
</ul>
2222

23-
<p>Return the largest number of points we can have after playing any number of tokens.</p>
23+
<p>Each token may be played <strong>at most</strong> once and <strong>in any order</strong>. You do <strong>not</strong> have to play all the tokens.</p>
2424

25-
<p>&nbsp;</p>
26-
27-
<ol>
28-
</ol>
25+
<p>Return <em>the largest possible <strong>score</strong> you can achieve after playing any number of tokens</em>.</p>
2926

30-
<div>
27+
<p>&nbsp;</p>
3128
<p><strong>Example 1:</strong></p>
3229

3330
<pre>
34-
<strong>Input: </strong>tokens = <span id="example-input-1-1">[100]</span>, P = <span id="example-input-1-2">50</span>
35-
<strong>Output: </strong><span id="example-output-1">0</span>
31+
<strong>Input:</strong> tokens = [100], P = 50
32+
<strong>Output:</strong> 0
33+
<strong>Explanation</strong><strong>:</strong> Playing the only token in the bag is impossible because you either have too little power or too little score.
3634
</pre>
3735

38-
<div>
3936
<p><strong>Example 2:</strong></p>
4037

4138
<pre>
42-
<strong>Input: </strong>tokens = <span id="example-input-2-1">[100,200]</span>, P = <span id="example-input-2-2">150</span>
43-
<strong>Output: </strong><span id="example-output-2">1</span>
39+
<strong>Input:</strong> tokens = [100,200], P = 150
40+
<strong>Output:</strong> 1
41+
<strong>Explanation:</strong> Play the 0<sup>th</sup> token (100) face up, your power becomes 50 and score becomes 1.
42+
There is no need to play the 1<sup>st</sup> token since you cannot play it face up to add to your score.
4443
</pre>
4544

46-
<div>
4745
<p><strong>Example 3:</strong></p>
4846

4947
<pre>
50-
<strong>Input: </strong>tokens = <span id="example-input-3-1">[100,200,300,400]</span>, P = <span id="example-input-3-2">200</span>
51-
<strong>Output: </strong><span id="example-output-3">2</span>
48+
<strong>Input:</strong> tokens = [100,200,300,400], P = 200
49+
<strong>Output:</strong> 2
50+
<strong>Explanation:</strong> Play the tokens in this order to get a score of 2:
51+
1. Play the 0<sup>th</sup> token (100) face up, your power becomes 100 and score becomes 1.
52+
2. Play the 3<sup>rd</sup> token (400) face down, your power becomes 500 and score becomes 0.
53+
3. Play the 1<sup>st</sup> token (200) face up, your power becomes 300 and score becomes 1.
54+
4. Play the 2<sup>nd </sup>token (300) face up, your power becomes 0 and score becomes 2.
5255
</pre>
5356

5457
<p>&nbsp;</p>
58+
<p><strong>Constraints:</strong></p>
5559

56-
<p><strong>Note:</strong></p>
57-
58-
<ol>
59-
<li><code>tokens.length &lt;= 1000</code></li>
60-
<li><code>0 &lt;= tokens[i] &lt; 10000</code></li>
61-
<li><code>0 &lt;= P &lt; 10000</code></li>
62-
</ol>
63-
</div>
64-
</div>
65-
</div>
60+
<ul>
61+
<li><code>0 &lt;= tokens.length &lt;= 1000</code></li>
62+
<li><code>0 &lt;= tokens[i],&nbsp;P &lt; 10<sup>4</sup></code></li>
63+
</ul>
6664

6765
### Related Topics
6866
[[Greedy](../../tag/greedy/README.md)]
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
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](../lexicographically-smallest-string-after-applying-operations "Lexicographically Smallest String After Applying Operations")
9+
                
10+
[Next >](../graph-connectivity-with-threshold "Graph Connectivity With Threshold")
11+
12+
## [1626. Best Team With No Conflicts (Medium)](https://leetcode.com/problems/best-team-with-no-conflicts "无矛盾的最佳球队")
13+
14+
<p>You are the manager of a basketball team. For the upcoming tournament, you want to choose the team with the highest overall score. The score of the team is the <strong>sum</strong> of scores of all the players in the team.</p>
15+
16+
<p>However, the basketball team is not allowed to have <strong>conflicts</strong>. A <strong>conflict</strong> exists if a younger player has a <strong>strictly higher</strong> score than an older player. A conflict does <strong>not</strong> occur between players of the same age.</p>
17+
18+
<p>Given two lists, <code>scores</code> and <code>ages</code>, where each <code>scores[i]</code> and <code>ages[i]</code> represents the score and age of the <code>i<sup>th</sup></code> player, respectively, return <em>the highest overall score of all possible basketball teams</em>.</p>
19+
20+
<p>&nbsp;</p>
21+
<p><strong>Example 1:</strong></p>
22+
23+
<pre>
24+
<strong>Input:</strong> scores = [1,3,5,10,15], ages = [1,2,3,4,5]
25+
<strong>Output:</strong> 34
26+
<strong>Explanation:</strong>&nbsp;You can choose all the players.
27+
</pre>
28+
29+
<p><strong>Example 2:</strong></p>
30+
31+
<pre>
32+
<strong>Input:</strong> scores = [4,5,6,5], ages = [2,1,2,1]
33+
<strong>Output:</strong> 16
34+
<strong>Explanation:</strong>&nbsp;It is best to choose the last 3 players. Notice that you are allowed to choose multiple people of the same age.
35+
</pre>
36+
37+
<p><strong>Example 3:</strong></p>
38+
39+
<pre>
40+
<strong>Input:</strong> scores = [1,2,3,5], ages = [8,9,10,1]
41+
<strong>Output:</strong> 6
42+
<strong>Explanation:</strong>&nbsp;It is best to choose the first 3 players.
43+
</pre>
44+
45+
<p>&nbsp;</p>
46+
<p><strong>Constraints:</strong></p>
47+
48+
<ul>
49+
<li><code>1 &lt;= scores.length, ages.length &lt;= 1000</code></li>
50+
<li><code>scores.length == ages.length</code></li>
51+
<li><code>1 &lt;= scores[i] &lt;= 10<sup>6</sup></code></li>
52+
<li><code>1 &lt;= ages[i] &lt;= 1000</code></li>
53+
</ul>
54+
55+
### Related Topics
56+
[[Dynamic Programming](../../tag/dynamic-programming/README.md)]
57+
58+
### Hints
59+
<details>
60+
<summary>Hint 1</summary>
61+
First, sort players by age and break ties by their score. You can now consider the players from left to right.
62+
</details>
63+
64+
<details>
65+
<summary>Hint 2</summary>
66+
If you choose to include a player, you must only choose players with at least that score later on.
67+
</details>

problems/customer-who-visited-but-did-not-make-any-transactions/README.md

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

1010
[Next >](../special-positions-in-a-binary-matrix "Special Positions in a Binary Matrix")
1111

12-
## [1581. Customer Who Visited but Did Not Make Any Transactions (Easy)](https://leetcode.com/problems/customer-who-visited-but-did-not-make-any-transactions "进店却未进行过交易的客户")
12+
## [1581. Customer Who Visited but Did Not Make Any Transactions (Easy)](https://leetcode.com/problems/customer-who-visited-but-did-not-make-any-transactions "进店却未进行过交易的顾客")
1313

1414

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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](../graph-connectivity-with-threshold "Graph Connectivity With Threshold")
9+
                
10+
Next >
11+
12+
## [1628. Design an Expression Tree With Evaluate Function (Medium)](https://leetcode.com/problems/design-an-expression-tree-with-evaluate-function "")
13+
14+
15+
16+
### Related Topics
17+
[[Tree](../../tag/tree/README.md)]
18+
[[Design](../../tag/design/README.md)]
19+
20+
### Hints
21+
<details>
22+
<summary>Hint 1</summary>
23+
Apply the concept of Polymorphism to get a good design
24+
</details>
25+
26+
<details>
27+
<summary>Hint 2</summary>
28+
Implement the Node class using NumericNode and OperatorNode classes.
29+
</details>
30+
31+
<details>
32+
<summary>Hint 3</summary>
33+
NumericNode only maintains the value, and evaluate returns this value.
34+
</details>
35+
36+
<details>
37+
<summary>Hint 4</summary>
38+
OperatorNode Maintains the left and right nodes representing the the left and right operands, and the evaluate function applies the operator to them.
39+
</details>

problems/escape-a-large-maze/README.md

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,44 +11,40 @@
1111

1212
## [1036. Escape a Large Maze (Hard)](https://leetcode.com/problems/escape-a-large-maze "逃离大迷宫")
1313

14-
<p>In a 1 million by 1 million grid, the coordinates of each grid square are <code>(x, y)</code> with <code>0 &lt;= x, y &lt; 10^6</code>.</p>
14+
<p>In a 1 million by 1 million grid, the coordinates of each grid square are <code>(x, y)</code>.</p>
1515

1616
<p>We start at the <code>source</code> square and want to reach the <code>target</code> square.&nbsp; Each move, we can walk to a 4-directionally adjacent square in the grid that isn&#39;t in the given list of <code>blocked</code> squares.</p>
1717

1818
<p>Return <code>true</code> if and only if it is possible to reach the target square through a sequence of moves.</p>
1919

2020
<p>&nbsp;</p>
21-
2221
<p><strong>Example 1:</strong></p>
2322

2423
<pre>
25-
<strong>Input: </strong>blocked = <span id="example-input-1-1">[[0,1],[1,0]]</span>, source = <span id="example-input-1-2">[0,0]</span>, target = <span id="example-input-1-3">[0,2]</span>
26-
<strong>Output: </strong><span id="example-output-1">false</span>
27-
<strong>Explanation: </strong>
28-
The target square is inaccessible starting from the source square, because we can&#39;t walk outside the grid.
24+
<strong>Input:</strong> blocked = [[0,1],[1,0]], source = [0,0], target = [0,2]
25+
<strong>Output:</strong> false
26+
<strong>Explanation:</strong> The target square is inaccessible starting from the source square, because we can&#39;t walk outside the grid.
2927
</pre>
3028

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

3331
<pre>
34-
<strong>Input: </strong>blocked = <span id="example-input-2-1">[]</span>, source = <span id="example-input-2-2">[0,0]</span>, target = <span id="example-input-2-3">[999999,999999]</span>
35-
<strong>Output: </strong><span id="example-output-2">true</span>
36-
<strong>Explanation: </strong>
37-
Because there are no blocked cells, it&#39;s possible to reach the target square.
32+
<strong>Input:</strong> blocked = [], source = [0,0], target = [999999,999999]
33+
<strong>Output:</strong> true
34+
<strong>Explanation:</strong> Because there are no blocked cells, it&#39;s possible to reach the target square.
3835
</pre>
3936

4037
<p>&nbsp;</p>
38+
<p><strong>Constraints:</strong></p>
4139

42-
<p><strong>Note:</strong></p>
43-
44-
<ol>
40+
<ul>
4541
<li><code>0 &lt;= blocked.length &lt;= 200</code></li>
4642
<li><code>blocked[i].length == 2</code></li>
4743
<li><code>0 &lt;= blocked[i][j] &lt; 10^6</code></li>
4844
<li><code>source.length == target.length == 2</code></li>
4945
<li><code>0 &lt;= source[i][j], target[i][j] &lt; 10^6</code></li>
5046
<li><code>source != target</code></li>
51-
</ol>
47+
</ul>
5248

5349
### Related Topics
5450
[[Breadth-first Search](../../tag/breadth-first-search/README.md)]

problems/fancy-sequence/README.md

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

88
[< Previous](../number-of-sets-of-k-non-overlapping-line-segments "Number of Sets of K Non-Overlapping Line Segments")
99

10-
Next >
10+
[Next >](../all-valid-triplets-that-can-represent-a-country "All Valid Triplets That Can Represent a Country")
1111

1212
## [1622. Fancy Sequence (Hard)](https://leetcode.com/problems/fancy-sequence "奇妙序列")
1313

0 commit comments

Comments
 (0)