Skip to content

Commit b89c05d

Browse files
author
Shuo
authored
Merge pull request #767 from openset/develop
Add: new
2 parents 6decf87 + 23e5bc8 commit b89c05d

File tree

38 files changed

+673
-33
lines changed

38 files changed

+673
-33
lines changed

README.md

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ LeetCode Problems' Solutions
6262

6363
| # | Title | Solution | Difficulty |
6464
| :-: | - | - | :-: |
65+
| <span id="1369">1369</span> | [Get the Second Most Recent Activity](https://leetcode.com/problems/get-the-second-most-recent-activity) 🔒 | [MySQL](problems/get-the-second-most-recent-activity) | Hard |
66+
| <span id="1368">1368</span> | [Minimum Cost to Make at Least One Valid Path in a Grid](https://leetcode.com/problems/minimum-cost-to-make-at-least-one-valid-path-in-a-grid "使网格图至少有一条有效路径的最小代价") | [Go](problems/minimum-cost-to-make-at-least-one-valid-path-in-a-grid) | Hard |
67+
| <span id="1367">1367</span> | [Linked List in Binary Tree](https://leetcode.com/problems/linked-list-in-binary-tree "二叉树中的列表") | [Go](problems/linked-list-in-binary-tree) | Medium |
68+
| <span id="1366">1366</span> | [Rank Teams by Votes](https://leetcode.com/problems/rank-teams-by-votes "通过投票对团队排名") | [Go](problems/rank-teams-by-votes) | Medium |
69+
| <span id="1365">1365</span> | [How Many Numbers Are Smaller Than the Current Number](https://leetcode.com/problems/how-many-numbers-are-smaller-than-the-current-number "有多少小于当前数字的数字") | [Go](problems/how-many-numbers-are-smaller-than-the-current-number) | Easy |
70+
| <span id="1364">1364</span> | [Number of Trusted Contacts of a Customer](https://leetcode.com/problems/number-of-trusted-contacts-of-a-customer "顾客的可信联系人数量") 🔒 | [MySQL](problems/number-of-trusted-contacts-of-a-customer) | Medium |
6571
| <span id="1363">1363</span> | [Largest Multiple of Three](https://leetcode.com/problems/largest-multiple-of-three "形成三的最大倍数") | [Go](problems/largest-multiple-of-three) | Hard |
6672
| <span id="1362">1362</span> | [Closest Divisors](https://leetcode.com/problems/closest-divisors "最接近的因数") | [Go](problems/closest-divisors) | Medium |
6773
| <span id="1361">1361</span> | [Validate Binary Tree Nodes](https://leetcode.com/problems/validate-binary-tree-nodes "验证二叉树") | [Go](problems/validate-binary-tree-nodes) | Medium |
@@ -75,7 +81,7 @@ LeetCode Problems' Solutions
7581
| <span id="1353">1353</span> | [Maximum Number of Events That Can Be Attended](https://leetcode.com/problems/maximum-number-of-events-that-can-be-attended "最多可以参加的会议数目") | [Go](problems/maximum-number-of-events-that-can-be-attended) | Medium |
7682
| <span id="1352">1352</span> | [Product of the Last K Numbers](https://leetcode.com/problems/product-of-the-last-k-numbers "最后 K 个数的乘积") | [Go](problems/product-of-the-last-k-numbers) | Medium |
7783
| <span id="1351">1351</span> | [Count Negative Numbers in a Sorted Matrix](https://leetcode.com/problems/count-negative-numbers-in-a-sorted-matrix "统计有序矩阵中的负数") | [Go](problems/count-negative-numbers-in-a-sorted-matrix) | Easy |
78-
| <span id="1350">1350</span> | [Students With Invalid Departments](https://leetcode.com/problems/students-with-invalid-departments) 🔒 | [MySQL](problems/students-with-invalid-departments) | Easy |
84+
| <span id="1350">1350</span> | [Students With Invalid Departments](https://leetcode.com/problems/students-with-invalid-departments "院系无效的学生") 🔒 | [MySQL](problems/students-with-invalid-departments) | Easy |
7985
| <span id="1349">1349</span> | [Maximum Students Taking Exam](https://leetcode.com/problems/maximum-students-taking-exam "参加考试的最大学生数") | [Go](problems/maximum-students-taking-exam) | Hard |
8086
| <span id="1348">1348</span> | [Tweet Counts Per Frequency](https://leetcode.com/problems/tweet-counts-per-frequency "推文计数") | [Go](problems/tweet-counts-per-frequency) | Medium |
8187
| <span id="1347">1347</span> | [Minimum Number of Steps to Make Two Strings Anagram](https://leetcode.com/problems/minimum-number-of-steps-to-make-two-strings-anagram "制造字母异位词的最小步骤数") | [Go](problems/minimum-number-of-steps-to-make-two-strings-anagram) | Medium |
@@ -89,7 +95,7 @@ LeetCode Problems' Solutions
8995
| <span id="1339">1339</span> | [Maximum Product of Splitted Binary Tree](https://leetcode.com/problems/maximum-product-of-splitted-binary-tree "分裂二叉树的最大乘积") | [Go](problems/maximum-product-of-splitted-binary-tree) | Medium |
9096
| <span id="1338">1338</span> | [Reduce Array Size to The Half](https://leetcode.com/problems/reduce-array-size-to-the-half "数组大小减半") | [Go](problems/reduce-array-size-to-the-half) | Medium |
9197
| <span id="1337">1337</span> | [The K Weakest Rows in a Matrix](https://leetcode.com/problems/the-k-weakest-rows-in-a-matrix "方阵中战斗力最弱的 K 行") | [Go](problems/the-k-weakest-rows-in-a-matrix) | Easy |
92-
| <span id="1336">1336</span> | [Number of Transactions per Visit](https://leetcode.com/problems/number-of-transactions-per-visit) 🔒 | [MySQL](problems/number-of-transactions-per-visit) | Hard |
98+
| <span id="1336">1336</span> | [Number of Transactions per Visit](https://leetcode.com/problems/number-of-transactions-per-visit "每次访问的交易次数") 🔒 | [MySQL](problems/number-of-transactions-per-visit) | Hard |
9399
| <span id="1335">1335</span> | [Minimum Difficulty of a Job Schedule](https://leetcode.com/problems/minimum-difficulty-of-a-job-schedule "工作计划的最低难度") | [Go](problems/minimum-difficulty-of-a-job-schedule) | Hard |
94100
| <span id="1334">1334</span> | [Find the City With the Smallest Number of Neighbors at a Threshold Distance](https://leetcode.com/problems/find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance "阈值距离内邻居最少的城市") | [Go](problems/find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance) | Medium |
95101
| <span id="1333">1333</span> | [Filter Restaurants by Vegan-Friendly, Price and Distance](https://leetcode.com/problems/filter-restaurants-by-vegan-friendly-price-and-distance "餐厅过滤器") | [Go](problems/filter-restaurants-by-vegan-friendly-price-and-distance) | Medium |
@@ -98,13 +104,13 @@ LeetCode Problems' Solutions
98104
| <span id="1330">1330</span> | [Reverse Subarray To Maximize Array Value](https://leetcode.com/problems/reverse-subarray-to-maximize-array-value "翻转子数组得到最大的数组值") | [Go](problems/reverse-subarray-to-maximize-array-value) | Hard |
99105
| <span id="1329">1329</span> | [Sort the Matrix Diagonally](https://leetcode.com/problems/sort-the-matrix-diagonally "将矩阵按对角线排序") | [Go](problems/sort-the-matrix-diagonally) | Medium |
100106
| <span id="1328">1328</span> | [Break a Palindrome](https://leetcode.com/problems/break-a-palindrome "破坏回文串") | [Go](problems/break-a-palindrome) | Medium |
101-
| <span id="1327">1327</span> | [List the Products Ordered in a Period](https://leetcode.com/problems/list-the-products-ordered-in-a-period) 🔒 | [MySQL](problems/list-the-products-ordered-in-a-period) | Easy |
107+
| <span id="1327">1327</span> | [List the Products Ordered in a Period](https://leetcode.com/problems/list-the-products-ordered-in-a-period "列出指定时间段内所有的下单产品") 🔒 | [MySQL](problems/list-the-products-ordered-in-a-period) | Easy |
102108
| <span id="1326">1326</span> | [Minimum Number of Taps to Open to Water a Garden](https://leetcode.com/problems/minimum-number-of-taps-to-open-to-water-a-garden "灌溉花园的最少水龙头数目") | [Go](problems/minimum-number-of-taps-to-open-to-water-a-garden) | Hard |
103109
| <span id="1325">1325</span> | [Delete Leaves With a Given Value](https://leetcode.com/problems/delete-leaves-with-a-given-value "删除给定值的叶子节点") | [Go](problems/delete-leaves-with-a-given-value) | Medium |
104110
| <span id="1324">1324</span> | [Print Words Vertically](https://leetcode.com/problems/print-words-vertically "竖直打印单词") | [Go](problems/print-words-vertically) | Medium |
105111
| <span id="1323">1323</span> | [Maximum 69 Number](https://leetcode.com/problems/maximum-69-number "6 和 9 组成的最大数字") | [Go](problems/maximum-69-number) | Easy |
106-
| <span id="1322">1322</span> | [Ads Performance](https://leetcode.com/problems/ads-performance) 🔒 | [MySQL](problems/ads-performance) | Easy |
107-
| <span id="1321">1321</span> | [Restaurant Growth](https://leetcode.com/problems/restaurant-growth) 🔒 | [MySQL](problems/restaurant-growth) | Medium |
112+
| <span id="1322">1322</span> | [Ads Performance](https://leetcode.com/problems/ads-performance "广告效果") 🔒 | [MySQL](problems/ads-performance) | Easy |
113+
| <span id="1321">1321</span> | [Restaurant Growth](https://leetcode.com/problems/restaurant-growth "餐馆营业额变化增长") 🔒 | [MySQL](problems/restaurant-growth) | Medium |
108114
| <span id="1320">1320</span> | [Minimum Distance to Type a Word Using Two Fingers](https://leetcode.com/problems/minimum-distance-to-type-a-word-using-two-fingers "二指输入的的最小距离") | [Go](problems/minimum-distance-to-type-a-word-using-two-fingers) | Hard |
109115
| <span id="1319">1319</span> | [Number of Operations to Make Network Connected](https://leetcode.com/problems/number-of-operations-to-make-network-connected "连通网络的操作次数") | [Go](problems/number-of-operations-to-make-network-connected) | Medium |
110116
| <span id="1318">1318</span> | [Minimum Flips to Make a OR b Equal to c](https://leetcode.com/problems/minimum-flips-to-make-a-or-b-equal-to-c "或运算的最小翻转次数") | [Go](problems/minimum-flips-to-make-a-or-b-equal-to-c) | Medium |
@@ -117,7 +123,7 @@ LeetCode Problems' Solutions
117123
| <span id="1311">1311</span> | [Get Watched Videos by Your Friends](https://leetcode.com/problems/get-watched-videos-by-your-friends "获取你好友已观看的视频") | [Go](problems/get-watched-videos-by-your-friends) | Medium |
118124
| <span id="1310">1310</span> | [XOR Queries of a Subarray](https://leetcode.com/problems/xor-queries-of-a-subarray "子数组异或查询") | [Go](problems/xor-queries-of-a-subarray) | Medium |
119125
| <span id="1309">1309</span> | [Decrypt String from Alphabet to Integer Mapping](https://leetcode.com/problems/decrypt-string-from-alphabet-to-integer-mapping "解码字母到整数映射") | [Go](problems/decrypt-string-from-alphabet-to-integer-mapping) | Easy |
120-
| <span id="1308">1308</span> | [Running Total for Different Genders](https://leetcode.com/problems/running-total-for-different-genders) 🔒 | [MySQL](problems/running-total-for-different-genders) | Medium |
126+
| <span id="1308">1308</span> | [Running Total for Different Genders](https://leetcode.com/problems/running-total-for-different-genders "不同性别每日分数总计") 🔒 | [MySQL](problems/running-total-for-different-genders) | Medium |
121127
| <span id="1307">1307</span> | [Verbal Arithmetic Puzzle](https://leetcode.com/problems/verbal-arithmetic-puzzle "口算难题") | [Go](problems/verbal-arithmetic-puzzle) | Hard |
122128
| <span id="1306">1306</span> | [Jump Game III](https://leetcode.com/problems/jump-game-iii "跳跃游戏 III") | [Go](problems/jump-game-iii) | Medium |
123129
| <span id="1305">1305</span> | [All Elements in Two Binary Search Trees](https://leetcode.com/problems/all-elements-in-two-binary-search-trees "两棵二叉搜索树中的所有元素") | [Go](problems/all-elements-in-two-binary-search-trees) | Medium |
@@ -266,7 +272,7 @@ LeetCode Problems' Solutions
266272
| <span id="1162">1162</span> | [As Far from Land as Possible](https://leetcode.com/problems/as-far-from-land-as-possible "地图分析") | [Go](problems/as-far-from-land-as-possible) | Medium |
267273
| <span id="1161">1161</span> | [Maximum Level Sum of a Binary Tree](https://leetcode.com/problems/maximum-level-sum-of-a-binary-tree "最大层内元素和") | [Go](problems/maximum-level-sum-of-a-binary-tree) | Medium |
268274
| <span id="1160">1160</span> | [Find Words That Can Be Formed by Characters](https://leetcode.com/problems/find-words-that-can-be-formed-by-characters "拼写单词") | [Go](problems/find-words-that-can-be-formed-by-characters) | Easy |
269-
| <span id="1159">1159</span> | [Market Analysis II](https://leetcode.com/problems/market-analysis-ii) 🔒 | [MySQL](problems/market-analysis-ii) | Hard |
275+
| <span id="1159">1159</span> | [Market Analysis II](https://leetcode.com/problems/market-analysis-ii "市场分析 II") 🔒 | [MySQL](problems/market-analysis-ii) | Hard |
270276
| <span id="1158">1158</span> | [Market Analysis I](https://leetcode.com/problems/market-analysis-i "市场分析 I") 🔒 | [MySQL](problems/market-analysis-i) | Medium |
271277
| <span id="1157">1157</span> | [Online Majority Element In Subarray](https://leetcode.com/problems/online-majority-element-in-subarray "子数组中占绝大多数的元素") | [Go](problems/online-majority-element-in-subarray) | Hard |
272278
| <span id="1156">1156</span> | [Swap For Longest Repeated Character Substring](https://leetcode.com/problems/swap-for-longest-repeated-character-substring "单字符重复子串的最大长度") | [Go](problems/swap-for-longest-repeated-character-substring) | Medium |

problems/activity-participants/README.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,68 @@
1111

1212
## [1355. Activity Participants (Medium)](https://leetcode.com/problems/activity-participants "")
1313

14+
<p>Table: <code>Friends</code></p>
15+
<pre>
16+
+---------------+---------+
17+
| Column Name | Type |
18+
+---------------+---------+
19+
| id | int |
20+
| name | varchar |
21+
| activity | varchar |
22+
+---------------+---------+
23+
id is the id of the friend and primary key for this table.
24+
name is the name of the friend.
25+
activity is the name of the activity which the friend takes part in.
26+
</pre>
1427

28+
<p>Table: <code>Activities</code></p>
29+
<pre>
30+
+---------------+---------+
31+
| Column Name | Type |
32+
+---------------+---------+
33+
| id | int |
34+
| name | varchar |
35+
+---------------+---------+
36+
id is the primary key for this table.
37+
name is the name of the activity.
38+
</pre>
39+
40+
Write an SQL query to find the names of all the activities with neither maximum, nor minimum number of participants.
41+
42+
Return the result table in any order. Each activity in table Activities is performed by any person in the table Friends.
43+
44+
The query result format is in the following example:
45+
46+
Friends table:
47+
<pre>
48+
+------+--------------+---------------+
49+
| id | name | activity |
50+
+------+--------------+---------------+
51+
| 1 | Jonathan D. | Eating |
52+
| 2 | Jade W. | Singing |
53+
| 3 | Victor J. | Singing |
54+
| 4 | Elvis Q. | Eating |
55+
| 5 | Daniel A. | Eating |
56+
| 6 | Bob B. | Horse Riding |
57+
+------+--------------+---------------+
58+
59+
Activities table:
60+
+------+--------------+
61+
| id | name |
62+
+------+--------------+
63+
| 1 | Eating |
64+
| 2 | Singing |
65+
| 3 | Horse Riding |
66+
+------+--------------+
67+
68+
Result table:
69+
+--------------+
70+
| results |
71+
+--------------+
72+
| Singing |
73+
+--------------+
74+
75+
Eating activity is performed by 3 friends, maximum number of participants, (Jonathan D. , Elvis Q. and Daniel A.)
76+
Horse Riding activity is performed by 1 friend, minimum number of participants, (Bob B.)
77+
Singing is performed by 2 friends (Victor J. and Jade W.)
78+
</pre>

problems/ads-performance/README.md

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

1010
[Next >](../maximum-69-number "Maximum 69 Number")
1111

12-
## [1322. Ads Performance (Easy)](https://leetcode.com/problems/ads-performance "")
12+
## [1322. Ads Performance (Easy)](https://leetcode.com/problems/ads-performance "广告效果")
1313

1414
<p>Table: <code>Ads</code></p>
1515
<pre>

problems/binary-search-tree-to-greater-sum-tree/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
<p>&nbsp;</p>
3737
</div>
3838

39-
<p><strong>Note:</strong></p>
39+
<p><strong>Constraints:</strong></p>
4040

4141
<ol>
4242
<li>The number of nodes in the tree is between <code>1</code> and <code>100</code>.</li>
@@ -46,7 +46,7 @@
4646

4747
<div>
4848
<div>
49-
<div>&nbsp;</div>
49+
<div><strong>Note:</strong> This question is the same as 538:&nbsp;<a href="https://leetcode.com/problems/convert-bst-to-greater-tree/">https://leetcode.com/problems/convert-bst-to-greater-tree/</a></div>
5050
</div>
5151
</div>
5252

problems/convert-bst-to-greater-tree/README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313

1414
<p>Given a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the original BST is changed to the original key plus sum of all keys greater than the original key in BST.</p>
1515

16-
<p>
17-
<b>Example:</b>
16+
<p><b>Example:</b></p>
17+
1818
<pre>
1919
<b>Input:</b> The root of a Binary Search Tree like this:
2020
5
@@ -26,7 +26,8 @@
2626
/ \
2727
20 13
2828
</pre>
29-
</p>
29+
30+
<p><strong>Note:</strong> This question is the same as&nbsp;1038:&nbsp;<a href="https://leetcode.com/problems/binary-search-tree-to-greater-sum-tree/">https://leetcode.com/problems/binary-search-tree-to-greater-sum-tree/</a></p>
3031

3132
### Related Topics
3233
[[Tree](../../tag/tree/README.md)]

problems/find-leaves-of-binary-tree/README.md

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

1010
[Next >](../valid-perfect-square "Valid Perfect Square")
1111

12-
## [366. Find Leaves of Binary Tree (Medium)](https://leetcode.com/problems/find-leaves-of-binary-tree "寻找完全二叉树的叶子节点")
12+
## [366. Find Leaves of Binary Tree (Medium)](https://leetcode.com/problems/find-leaves-of-binary-tree "寻找二叉树的叶子节点")
1313

1414
<p>Given a binary tree, collect a tree&#39;s nodes as if you were doing this: Collect and remove all leaves, repeat until the tree is empty.</p>
1515

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 <openset.wang@gmail.com> |-->
4+
<!--|@link https://github.com/openset |-->
5+
<!--|@home https://github.com/openset/leetcode |-->
6+
<!--+----------------------------------------------------------------------+-->
7+
8+
[< Previous](../minimum-cost-to-make-at-least-one-valid-path-in-a-grid "Minimum Cost to Make at Least One Valid Path in a Grid")
9+
                
10+
Next >
11+
12+
## [1369. Get the Second Most Recent Activity (Hard)](https://leetcode.com/problems/get-the-second-most-recent-activity "")
13+
14+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Create table If Not Exists UserActivity (username varchar(30), activity varchar(30), startDate date, endDate date);
2+
Truncate table UserActivity;
3+
insert into UserActivity (username, activity, startDate, endDate) values ('Alice', 'Travel', '2020-02-12', '2020-02-20');
4+
insert into UserActivity (username, activity, startDate, endDate) values ('Alice', 'Dancing', '2020-02-21', '2020-02-23');
5+
insert into UserActivity (username, activity, startDate, endDate) values ('Alice', 'Travel', '2020-02-24', '2020-02-28');
6+
insert into UserActivity (username, activity, startDate, endDate) values ('Bob', 'Travel', '2020-02-11', '2020-02-18');

problems/height-checker/README.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,32 @@
1717

1818
<p>&nbsp;</p>
1919
<p><strong>Example 1:</strong></p>
20-
<pre><strong>Input:</strong> heights = [1,1,4,2,1,3]
20+
21+
<pre>
22+
<strong>Input:</strong> heights = [1,1,4,2,1,3]
2123
<strong>Output:</strong> 3
24+
<strong>Explanation:</strong>
25+
Current array : [1,1,4,2,1,3]
26+
Target array : [1,1,1,2,3,4]
27+
On index 2 (0-based) we have 4 vs 1 so we have to move this student.
28+
On index 4 (0-based) we have 1 vs 3 so we have to move this student.
29+
On index 5 (0-based) we have 3 vs 4 so we have to move this student.
30+
</pre>
31+
32+
<p><strong>Example 2:</strong></p>
33+
34+
<pre>
35+
<strong>Input:</strong> heights = [5,1,2,3,4]
36+
<strong>Output:</strong> 5
2237
</pre>
38+
39+
<p><strong>Example 3:</strong></p>
40+
41+
<pre>
42+
<strong>Input:</strong> heights = [1,2,3,4,5]
43+
<strong>Output:</strong> 0
44+
</pre>
45+
2346
<p>&nbsp;</p>
2447
<p><strong>Constraints:</strong></p>
2548

0 commit comments

Comments
 (0)