Skip to content

Commit 01e0aa5

Browse files
author
Shuo
committed
Add: new
1 parent 7569133 commit 01e0aa5

File tree

36 files changed

+450
-33
lines changed

36 files changed

+450
-33
lines changed

README.md

+13-7
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/ads-performance/README.md

+1-1
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

+2-2
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

+4-3
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

+1-1
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

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](../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+
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

+24-1
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

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](../number-of-trusted-contacts-of-a-customer "Number of Trusted Contacts of a Customer")
9+
                
10+
[Next >](../rank-teams-by-votes "Rank Teams by Votes")
11+
12+
## [1365. How Many Numbers Are Smaller Than the Current Number (Easy)](https://leetcode.com/problems/how-many-numbers-are-smaller-than-the-current-number "有多少小于当前数字的数字")
13+
14+
<p>Given the array <code>nums</code>, for each <code>nums[i]</code> find out how many numbers in the array are smaller than it. That is, for each <code>nums[i]</code> you have to count the number of valid <code>j&#39;s</code>&nbsp;such that&nbsp;<code>j != i</code> <strong>and</strong> <code>nums[j] &lt; nums[i]</code>.</p>
15+
16+
<p>Return the answer in an array.</p>
17+
18+
<p>&nbsp;</p>
19+
<p><strong>Example 1:</strong></p>
20+
21+
<pre>
22+
<strong>Input:</strong> nums = [8,1,2,2,3]
23+
<strong>Output:</strong> [4,0,1,1,3]
24+
<strong>Explanation:</strong>
25+
For nums[0]=8 there exist four smaller numbers than it (1, 2, 2 and 3).
26+
For nums[1]=1 does not exist any smaller number than it.
27+
For nums[2]=2 there exist one smaller number than it (1).
28+
For nums[3]=2 there exist one smaller number than it (1).
29+
For nums[4]=3 there exist three smaller numbers than it (1, 2 and 2).
30+
</pre>
31+
32+
<p><strong>Example 2:</strong></p>
33+
34+
<pre>
35+
<strong>Input:</strong> nums = [6,5,4,8]
36+
<strong>Output:</strong> [2,1,0,3]
37+
</pre>
38+
39+
<p><strong>Example 3:</strong></p>
40+
41+
<pre>
42+
<strong>Input:</strong> nums = [7,7,7,7]
43+
<strong>Output:</strong> [0,0,0,0]
44+
</pre>
45+
46+
<p>&nbsp;</p>
47+
<p><strong>Constraints:</strong></p>
48+
49+
<ul>
50+
<li><code>2 &lt;= nums.length &lt;= 500</code></li>
51+
<li><code>0 &lt;= nums[i] &lt;= 100</code></li>
52+
</ul>
53+
54+
### Related Topics
55+
[[Array](../../tag/array/README.md)]
56+
[[Hash Table](../../tag/hash-table/README.md)]
57+
58+
### Hints
59+
<details>
60+
<summary>Hint 1</summary>
61+
Brute force for each array element.
62+
</details>
63+
64+
<details>
65+
<summary>Hint 2</summary>
66+
In order to improve the time complexity, we can sort the array and get the answer for each array element.
67+
</details>

problems/largest-multiple-of-three/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
[< Previous](../closest-divisors "Closest Divisors")
99

10-
Next >
10+
[Next >](../number-of-trusted-contacts-of-a-customer "Number of Trusted Contacts of a Customer")
1111

1212
## [1363. Largest Multiple of Three (Hard)](https://leetcode.com/problems/largest-multiple-of-three "形成三的最大倍数")
1313

0 commit comments

Comments
 (0)