Skip to content

Commit 59e72d4

Browse files
author
openset
committed
Add: new
1 parent 9c83491 commit 59e72d4

File tree

31 files changed

+545
-18
lines changed

31 files changed

+545
-18
lines changed

README.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,22 @@ LeetCode Problems' Solutions
6262

6363
| # | Title | Solution | Difficulty |
6464
| :-: | - | - | :-: |
65+
| <span id="1220">1220</span> | [Count Vowels Permutation](https://leetcode.com/problems/count-vowels-permutation "统计元音字母序列的数目") | [Go](https://github.com/openset/leetcode/tree/master/problems/count-vowels-permutation) | Hard |
66+
| <span id="1219">1219</span> | [Path with Maximum Gold](https://leetcode.com/problems/path-with-maximum-gold "黄金矿工") | [Go](https://github.com/openset/leetcode/tree/master/problems/path-with-maximum-gold) | Medium |
67+
| <span id="1218">1218</span> | [Longest Arithmetic Subsequence of Given Difference](https://leetcode.com/problems/longest-arithmetic-subsequence-of-given-difference "最长定差子序列") | [Go](https://github.com/openset/leetcode/tree/master/problems/longest-arithmetic-subsequence-of-given-difference) | Medium |
68+
| <span id="1217">1217</span> | [Play with Chips](https://leetcode.com/problems/play-with-chips "玩筹码") | [Go](https://github.com/openset/leetcode/tree/master/problems/play-with-chips) | Easy |
69+
| <span id="1216">1216</span> | [Valid Palindrome III](https://leetcode.com/problems/valid-palindrome-iii "验证回文字符串 III") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/valid-palindrome-iii) | Hard |
70+
| <span id="1215">1215</span> | [Stepping Numbers](https://leetcode.com/problems/stepping-numbers "步进数") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/stepping-numbers) | Medium |
71+
| <span id="1214">1214</span> | [Two Sum BSTs](https://leetcode.com/problems/two-sum-bsts "查找两棵二叉搜索树之和") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/two-sum-bsts) | Medium |
72+
| <span id="1213">1213</span> | [Intersection of Three Sorted Arrays](https://leetcode.com/problems/intersection-of-three-sorted-arrays "三个有序数组的交集") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/intersection-of-three-sorted-arrays) | Easy |
73+
| <span id="1212">1212</span> | [Team Scores in Football Tournament](https://leetcode.com/problems/team-scores-in-football-tournament) 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/team-scores-in-football-tournament) | Medium |
74+
| <span id="1211">1211</span> | [Queries Quality and Percentage](https://leetcode.com/problems/queries-quality-and-percentage) 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/queries-quality-and-percentage) | Easy |
6575
| <span id="1210">1210</span> | [Minimum Moves to Reach Target with Rotations](https://leetcode.com/problems/minimum-moves-to-reach-target-with-rotations "穿过迷宫的最少移动次数") | [Go](https://github.com/openset/leetcode/tree/master/problems/minimum-moves-to-reach-target-with-rotations) | Hard |
6676
| <span id="1209">1209</span> | [Remove All Adjacent Duplicates in String II](https://leetcode.com/problems/remove-all-adjacent-duplicates-in-string-ii "删除字符串中的所有相邻重复项 II") | [Go](https://github.com/openset/leetcode/tree/master/problems/remove-all-adjacent-duplicates-in-string-ii) | Medium |
6777
| <span id="1208">1208</span> | [Get Equal Substrings Within Budget](https://leetcode.com/problems/get-equal-substrings-within-budget "尽可能使字符串相等") | [Go](https://github.com/openset/leetcode/tree/master/problems/get-equal-substrings-within-budget) | Medium |
6878
| <span id="1207">1207</span> | [Unique Number of Occurrences](https://leetcode.com/problems/unique-number-of-occurrences "独一无二的出现次数") | [Go](https://github.com/openset/leetcode/tree/master/problems/unique-number-of-occurrences) | Easy |
69-
| <span id="1206">1206</span> | [Design Skiplist](https://leetcode.com/problems/design-skiplist) | [Go](https://github.com/openset/leetcode/tree/master/problems/design-skiplist) | Hard |
70-
| <span id="1205">1205</span> | [Monthly Transactions II](https://leetcode.com/problems/monthly-transactions-ii) 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/monthly-transactions-ii) | Medium |
79+
| <span id="1206">1206</span> | [Design Skiplist](https://leetcode.com/problems/design-skiplist "设计跳表") | [Go](https://github.com/openset/leetcode/tree/master/problems/design-skiplist) | Hard |
80+
| <span id="1205">1205</span> | [Monthly Transactions II](https://leetcode.com/problems/monthly-transactions-ii "每月交易II") 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/monthly-transactions-ii) | Medium |
7181
| <span id="1204">1204</span> | [Last Person to Fit in the Elevator](https://leetcode.com/problems/last-person-to-fit-in-the-elevator) 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/last-person-to-fit-in-the-elevator) | Medium |
7282
| <span id="1203">1203</span> | [Sort Items by Groups Respecting Dependencies](https://leetcode.com/problems/sort-items-by-groups-respecting-dependencies "项目管理") | [Go](https://github.com/openset/leetcode/tree/master/problems/sort-items-by-groups-respecting-dependencies) | Hard |
7383
| <span id="1202">1202</span> | [Smallest String With Swaps](https://leetcode.com/problems/smallest-string-with-swaps "交换字符串中的元素") | [Go](https://github.com/openset/leetcode/tree/master/problems/smallest-string-with-swaps) | Medium |
@@ -78,7 +88,7 @@ LeetCode Problems' Solutions
7888
| <span id="1197">1197</span> | [Minimum Knight Moves](https://leetcode.com/problems/minimum-knight-moves "进击的骑士") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/minimum-knight-moves) | Medium |
7989
| <span id="1196">1196</span> | [How Many Apples Can You Put into the Basket](https://leetcode.com/problems/how-many-apples-can-you-put-into-the-basket "最多可以买到的苹果数量") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/how-many-apples-can-you-put-into-the-basket) | Easy |
8090
| <span id="1195">1195</span> | [Fizz Buzz Multithreaded](https://leetcode.com/problems/fizz-buzz-multithreaded "交替打印字符串") | [Go](https://github.com/openset/leetcode/tree/master/problems/fizz-buzz-multithreaded) | Medium |
81-
| <span id="1194">1194</span> | [Tournament Winners](https://leetcode.com/problems/tournament-winners) 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/tournament-winners) | Hard |
91+
| <span id="1194">1194</span> | [Tournament Winners](https://leetcode.com/problems/tournament-winners "锦标赛优胜者") 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/tournament-winners) | Hard |
8292
| <span id="1193">1193</span> | [Monthly Transactions I](https://leetcode.com/problems/monthly-transactions-i "每月交易 I") 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/monthly-transactions-i) | Medium |
8393
| <span id="1192">1192</span> | [Critical Connections in a Network](https://leetcode.com/problems/critical-connections-in-a-network "查找集群内的「关键连接」") | [Go](https://github.com/openset/leetcode/tree/master/problems/critical-connections-in-a-network) | Hard |
8494
| <span id="1191">1191</span> | [K-Concatenation Maximum Sum](https://leetcode.com/problems/k-concatenation-maximum-sum "K 次串联后最大子数组之和") | [Go](https://github.com/openset/leetcode/tree/master/problems/k-concatenation-maximum-sum) | Medium |
@@ -175,7 +185,7 @@ LeetCode Problems' Solutions
175185
| <span id="1100">1100</span> | [Find K-Length Substrings With No Repeated Characters](https://leetcode.com/problems/find-k-length-substrings-with-no-repeated-characters "长度为 K 的无重复字符子串") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/find-k-length-substrings-with-no-repeated-characters) | Medium |
176186
| <span id="1099">1099</span> | [Two Sum Less Than K](https://leetcode.com/problems/two-sum-less-than-k "小于 K 的两数之和") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/two-sum-less-than-k) | Easy |
177187
| <span id="1098">1098</span> | [Unpopular Books](https://leetcode.com/problems/unpopular-books "小众书籍") 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/unpopular-books) | Medium |
178-
| <span id="1097">1097</span> | [Game Play Analysis V](https://leetcode.com/problems/game-play-analysis-v) 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/game-play-analysis-v) | Hard |
188+
| <span id="1097">1097</span> | [Game Play Analysis V](https://leetcode.com/problems/game-play-analysis-v "游戏玩法分析 V") 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/game-play-analysis-v) | Hard |
179189
| <span id="1096">1096</span> | [Brace Expansion II](https://leetcode.com/problems/brace-expansion-ii "花括号展开 II") | [Go](https://github.com/openset/leetcode/tree/master/problems/brace-expansion-ii) | Hard |
180190
| <span id="1095">1095</span> | [Find in Mountain Array](https://leetcode.com/problems/find-in-mountain-array "山脉数组中查找目标值") | [Go](https://github.com/openset/leetcode/tree/master/problems/find-in-mountain-array) | Hard |
181191
| <span id="1094">1094</span> | [Car Pooling](https://leetcode.com/problems/car-pooling "拼车") | [Go](https://github.com/openset/leetcode/tree/master/problems/car-pooling) | Medium |
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
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](https://github.com/openset/leetcode/tree/master/problems/path-with-maximum-gold "Path with Maximum Gold")
9+
                
10+
Next >
11+
12+
## [5216. Count Vowels Permutation (Hard)](https://leetcode.com/problems/count-vowels-permutation "统计元音字母序列的数目")
13+
14+
<p>Given an integer <code>n</code>, your task is to count how many strings of length <code>n</code> can be formed under the following rules:</p>
15+
16+
<ul>
17+
<li>Each character is a lower case vowel&nbsp;(<code>&#39;a&#39;</code>, <code>&#39;e&#39;</code>, <code>&#39;i&#39;</code>, <code>&#39;o&#39;</code>, <code>&#39;u&#39;</code>)</li>
18+
<li>Each vowel&nbsp;<code>&#39;a&#39;</code> may only be followed by an <code>&#39;e&#39;</code>.</li>
19+
<li>Each vowel&nbsp;<code>&#39;e&#39;</code> may only be followed by an <code>&#39;a&#39;</code>&nbsp;or an <code>&#39;i&#39;</code>.</li>
20+
<li>Each vowel&nbsp;<code>&#39;i&#39;</code> <strong>may not</strong> be followed by another <code>&#39;i&#39;</code>.</li>
21+
<li>Each vowel&nbsp;<code>&#39;o&#39;</code> may only be followed by an <code>&#39;i&#39;</code> or a&nbsp;<code>&#39;u&#39;</code>.</li>
22+
<li>Each vowel&nbsp;<code>&#39;u&#39;</code> may only be followed by an <code>&#39;a&#39;.</code></li>
23+
</ul>
24+
25+
<p>Since the answer&nbsp;may be too large,&nbsp;return it modulo <code>10^9 + 7.</code></p>
26+
27+
<p>&nbsp;</p>
28+
<p><strong>Example 1:</strong></p>
29+
30+
<pre>
31+
<strong>Input:</strong> n = 1
32+
<strong>Output:</strong> 5
33+
<strong>Explanation:</strong> All possible strings are: &quot;a&quot;, &quot;e&quot;, &quot;i&quot; , &quot;o&quot; and &quot;u&quot;.
34+
</pre>
35+
36+
<p><strong>Example 2:</strong></p>
37+
38+
<pre>
39+
<strong>Input:</strong> n = 2
40+
<strong>Output:</strong> 10
41+
<strong>Explanation:</strong> All possible strings are: &quot;ae&quot;, &quot;ea&quot;, &quot;ei&quot;, &quot;ia&quot;, &quot;ie&quot;, &quot;io&quot;, &quot;iu&quot;, &quot;oi&quot;, &quot;ou&quot; and &quot;ua&quot;.
42+
</pre>
43+
44+
<p><strong>Example 3:&nbsp;</strong></p>
45+
46+
<pre>
47+
<strong>Input:</strong> n = 5
48+
<strong>Output:</strong> 68</pre>
49+
50+
<p>&nbsp;</p>
51+
<p><strong>Constraints:</strong></p>
52+
53+
<ul>
54+
<li><code>1 &lt;= n &lt;= 2 * 10^4</code></li>
55+
</ul>
56+
57+
### Hints
58+
<details>
59+
<summary>Hint 1</summary>
60+
Use dynamic programming.
61+
</details>
62+
63+
<details>
64+
<summary>Hint 2</summary>
65+
Let dp[i][j] be the number of strings of length i that ends with the j-th vowel.
66+
</details>
67+
68+
<details>
69+
<summary>Hint 3</summary>
70+
Deduce the recurrence from the given relations between vowels.
71+
</details>

problems/design-skiplist/README.md

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

1010
[Next >](https://github.com/openset/leetcode/tree/master/problems/unique-number-of-occurrences "Unique Number of Occurrences")
1111

12-
## [1206. Design Skiplist (Hard)](https://leetcode.com/problems/design-skiplist "")
12+
## [1206. Design Skiplist (Hard)](https://leetcode.com/problems/design-skiplist "设计跳表")
1313

1414
<p>Design a Skiplist without using any built-in libraries.</p>
1515

problems/game-play-analysis-v/README.md

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

1010
[Next >](https://github.com/openset/leetcode/tree/master/problems/unpopular-books "Unpopular Books")
1111

12-
## [1097. Game Play Analysis V (Hard)](https://leetcode.com/problems/game-play-analysis-v "")
12+
## [1097. Game Play Analysis V (Hard)](https://leetcode.com/problems/game-play-analysis-v "游戏玩法分析 V")
1313

1414

1515

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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](https://github.com/openset/leetcode/tree/master/problems/team-scores-in-football-tournament "Team Scores in Football Tournament")
9+
                
10+
[Next >](https://github.com/openset/leetcode/tree/master/problems/two-sum-bsts "Two Sum BSTs")
11+
12+
## [5079. Intersection of Three Sorted Arrays (Easy)](https://leetcode.com/problems/intersection-of-three-sorted-arrays "三个有序数组的交集")
13+
14+
<p>Given three integer arrays <code>arr1</code>, <code>arr2</code> and <code>arr3</code>&nbsp;<strong>sorted</strong> in <strong>strictly increasing</strong> order, return a sorted array of <strong>only</strong>&nbsp;the&nbsp;integers that appeared in <strong>all</strong> three arrays.</p>
15+
16+
<p>&nbsp;</p>
17+
<p><strong>Example 1:</strong></p>
18+
19+
<pre>
20+
<strong>Input:</strong> arr1 = [1,2,3,4,5], arr2 = [1,2,5,7,9], arr3 = [1,3,4,5,8]
21+
<strong>Output:</strong> [1,5]
22+
<strong>Explanation: </strong>Only 1 and 5 appeared in the three arrays.
23+
</pre>
24+
25+
<p>&nbsp;</p>
26+
<p><strong>Constraints:</strong></p>
27+
28+
<ul>
29+
<li><code>1 &lt;= arr1.length, arr2.length, arr3.length &lt;= 1000</code></li>
30+
<li><code>1 &lt;= arr1[i], arr2[i], arr3[i] &lt;= 2000</code></li>
31+
</ul>
32+
33+
### Related Topics
34+
[[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)]
35+
[[Two Pointers](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)]
36+
37+
### Similar Questions
38+
1. [Intersection of Two Arrays](https://github.com/openset/leetcode/tree/master/problems/intersection-of-two-arrays) (Easy)
39+
40+
### Hints
41+
<details>
42+
<summary>Hint 1</summary>
43+
Count the frequency of all elements in the three arrays.
44+
</details>
45+
46+
<details>
47+
<summary>Hint 2</summary>
48+
The elements that appeared in all the arrays would have a frequency of 3.
49+
</details>

problems/intersection-of-two-arrays/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,4 @@
4545

4646
### Similar Questions
4747
1. [Intersection of Two Arrays II](https://github.com/openset/leetcode/tree/master/problems/intersection-of-two-arrays-ii) (Easy)
48+
1. [Intersection of Three Sorted Arrays](https://github.com/openset/leetcode/tree/master/problems/intersection-of-three-sorted-arrays) (Easy)
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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](https://github.com/openset/leetcode/tree/master/problems/play-with-chips "Play with Chips")
9+
                
10+
[Next >](https://github.com/openset/leetcode/tree/master/problems/path-with-maximum-gold "Path with Maximum Gold")
11+
12+
## [5214. Longest Arithmetic Subsequence of Given Difference (Medium)](https://leetcode.com/problems/longest-arithmetic-subsequence-of-given-difference "最长定差子序列")
13+
14+
<p>Given an integer array <code>arr</code>&nbsp;and an integer <code><font face="monospace">difference</font></code>, return the length of the longest arithmetic subsequence in <font face="monospace"><code>arr</code>&nbsp;</font>such that the difference between adjacent elements in the subsequence equals&nbsp;<code>difference</code>.</p>
15+
16+
<p>&nbsp;</p>
17+
<p><strong>Example 1:</strong></p>
18+
19+
<pre>
20+
<strong>Input:</strong> arr = [1,2,3,4], difference = 1
21+
<strong>Output:</strong> 4
22+
<strong>Explanation: </strong>The longest arithmetic subsequence is [1,2,3,4].</pre>
23+
24+
<p><strong>Example 2:</strong></p>
25+
26+
<pre>
27+
<strong>Input:</strong> arr = [1,3,5,7], difference = 1
28+
<strong>Output:</strong> 1
29+
<strong>Explanation: </strong>The longest arithmetic subsequence is any single element.
30+
</pre>
31+
32+
<p><strong>Example 3:</strong></p>
33+
34+
<pre>
35+
<strong>Input:</strong> arr = [1,5,7,8,5,3,4,2,1], difference = -2
36+
<strong>Output:</strong> 4
37+
<strong>Explanation: </strong>The longest arithmetic subsequence is [7,5,3,1].
38+
</pre>
39+
40+
<p>&nbsp;</p>
41+
<p><strong>Constraints:</strong></p>
42+
43+
<ul>
44+
<li><code>1 &lt;= arr.length &lt;= 10^5</code></li>
45+
<li><code>-10^4 &lt;= arr[i], difference &lt;= 10^4</code></li>
46+
</ul>

problems/minimum-moves-to-reach-target-with-rotations/README.md

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

88
[< Previous](https://github.com/openset/leetcode/tree/master/problems/remove-all-adjacent-duplicates-in-string-ii "Remove All Adjacent Duplicates in String II")
99

10-
Next >
10+
[Next >](https://github.com/openset/leetcode/tree/master/problems/queries-quality-and-percentage "Queries Quality and Percentage")
1111

1212
## [5208. Minimum Moves to Reach Target with Rotations (Hard)](https://leetcode.com/problems/minimum-moves-to-reach-target-with-rotations "穿过迷宫的最少移动次数")
1313

problems/monthly-transactions-ii/README.md

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

1010
[Next >](https://github.com/openset/leetcode/tree/master/problems/design-skiplist "Design Skiplist")
1111

12-
## [1205. Monthly Transactions II (Medium)](https://leetcode.com/problems/monthly-transactions-ii "")
12+
## [1205. Monthly Transactions II (Medium)](https://leetcode.com/problems/monthly-transactions-ii "每月交易II")
1313

1414

problems/moving-average-from-data-stream/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,19 @@
1111

1212
## [346. Moving Average from Data Stream (Easy)](https://leetcode.com/problems/moving-average-from-data-stream "数据流中的移动平均值")
1313

14+
<p>Given a stream of integers and a window size, calculate the moving average of all integers in the sliding window.</p>
1415

16+
<p><strong>Example:</strong></p>
17+
18+
<pre>
19+
MovingAverage m = new MovingAverage(3);
20+
m.next(1) = 1
21+
m.next(10) = (1 + 10) / 2
22+
m.next(3) = (1 + 10 + 3) / 3
23+
m.next(5) = (10 + 3 + 5) / 3
24+
</pre>
25+
26+
<p>&nbsp;</p>
1527

1628
### Related Topics
1729
[[Design](https://github.com/openset/leetcode/tree/master/tag/design/README.md)]

0 commit comments

Comments
 (0)