Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,22 @@ LeetCode Problems' Solutions

| # | Title | Solution | Difficulty |
| :-: | - | - | :-: |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
Expand All @@ -78,7 +88,7 @@ LeetCode Problems' Solutions
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
Expand Down Expand Up @@ -175,7 +185,7 @@ LeetCode Problems' Solutions
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
Expand Down
71 changes: 71 additions & 0 deletions problems/count-vowels-permutation/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<!--|This file generated by command(leetcode description); DO NOT EDIT. |-->
<!--+----------------------------------------------------------------------+-->
<!--|@author openset <openset.wang@gmail.com> |-->
<!--|@link https://github.com/openset |-->
<!--|@home https://github.com/openset/leetcode |-->
<!--+----------------------------------------------------------------------+-->

[< Previous](https://github.com/openset/leetcode/tree/master/problems/path-with-maximum-gold "Path with Maximum Gold")

Next >

## [5216. Count Vowels Permutation (Hard)](https://leetcode.com/problems/count-vowels-permutation "统计元音字母序列的数目")

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

<ul>
<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>
<li>Each vowel&nbsp;<code>&#39;a&#39;</code> may only be followed by an <code>&#39;e&#39;</code>.</li>
<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>
<li>Each vowel&nbsp;<code>&#39;i&#39;</code> <strong>may not</strong> be followed by another <code>&#39;i&#39;</code>.</li>
<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>
<li>Each vowel&nbsp;<code>&#39;u&#39;</code> may only be followed by an <code>&#39;a&#39;.</code></li>
</ul>

<p>Since the answer&nbsp;may be too large,&nbsp;return it modulo <code>10^9 + 7.</code></p>

<p>&nbsp;</p>
<p><strong>Example 1:</strong></p>

<pre>
<strong>Input:</strong> n = 1
<strong>Output:</strong> 5
<strong>Explanation:</strong> All possible strings are: &quot;a&quot;, &quot;e&quot;, &quot;i&quot; , &quot;o&quot; and &quot;u&quot;.
</pre>

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

<pre>
<strong>Input:</strong> n = 2
<strong>Output:</strong> 10
<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;.
</pre>

<p><strong>Example 3:&nbsp;</strong></p>

<pre>
<strong>Input:</strong> n = 5
<strong>Output:</strong> 68</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
<li><code>1 &lt;= n &lt;= 2 * 10^4</code></li>
</ul>

### Hints
<details>
<summary>Hint 1</summary>
Use dynamic programming.
</details>

<details>
<summary>Hint 2</summary>
Let dp[i][j] be the number of strings of length i that ends with the j-th vowel.
</details>

<details>
<summary>Hint 3</summary>
Deduce the recurrence from the given relations between vowels.
</details>
2 changes: 1 addition & 1 deletion problems/design-skiplist/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

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

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

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

Expand Down
2 changes: 1 addition & 1 deletion problems/game-play-analysis-v/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

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

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



Expand Down
49 changes: 49 additions & 0 deletions problems/intersection-of-three-sorted-arrays/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<!--|This file generated by command(leetcode description); DO NOT EDIT. |-->
<!--+----------------------------------------------------------------------+-->
<!--|@author openset <openset.wang@gmail.com> |-->
<!--|@link https://github.com/openset |-->
<!--|@home https://github.com/openset/leetcode |-->
<!--+----------------------------------------------------------------------+-->

[< Previous](https://github.com/openset/leetcode/tree/master/problems/team-scores-in-football-tournament "Team Scores in Football Tournament")

[Next >](https://github.com/openset/leetcode/tree/master/problems/two-sum-bsts "Two Sum BSTs")

## [5079. Intersection of Three Sorted Arrays (Easy)](https://leetcode.com/problems/intersection-of-three-sorted-arrays "三个有序数组的交集")

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

<p>&nbsp;</p>
<p><strong>Example 1:</strong></p>

<pre>
<strong>Input:</strong> arr1 = [1,2,3,4,5], arr2 = [1,2,5,7,9], arr3 = [1,3,4,5,8]
<strong>Output:</strong> [1,5]
<strong>Explanation: </strong>Only 1 and 5 appeared in the three arrays.
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
<li><code>1 &lt;= arr1.length, arr2.length, arr3.length &lt;= 1000</code></li>
<li><code>1 &lt;= arr1[i], arr2[i], arr3[i] &lt;= 2000</code></li>
</ul>

### Related Topics
[[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)]
[[Two Pointers](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)]

### Similar Questions
1. [Intersection of Two Arrays](https://github.com/openset/leetcode/tree/master/problems/intersection-of-two-arrays) (Easy)

### Hints
<details>
<summary>Hint 1</summary>
Count the frequency of all elements in the three arrays.
</details>

<details>
<summary>Hint 2</summary>
The elements that appeared in all the arrays would have a frequency of 3.
</details>
1 change: 1 addition & 0 deletions problems/intersection-of-two-arrays/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,4 @@

### Similar Questions
1. [Intersection of Two Arrays II](https://github.com/openset/leetcode/tree/master/problems/intersection-of-two-arrays-ii) (Easy)
1. [Intersection of Three Sorted Arrays](https://github.com/openset/leetcode/tree/master/problems/intersection-of-three-sorted-arrays) (Easy)
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<!--|This file generated by command(leetcode description); DO NOT EDIT. |-->
<!--+----------------------------------------------------------------------+-->
<!--|@author openset <openset.wang@gmail.com> |-->
<!--|@link https://github.com/openset |-->
<!--|@home https://github.com/openset/leetcode |-->
<!--+----------------------------------------------------------------------+-->

[< Previous](https://github.com/openset/leetcode/tree/master/problems/play-with-chips "Play with Chips")

[Next >](https://github.com/openset/leetcode/tree/master/problems/path-with-maximum-gold "Path with Maximum Gold")

## [5214. Longest Arithmetic Subsequence of Given Difference (Medium)](https://leetcode.com/problems/longest-arithmetic-subsequence-of-given-difference "最长定差子序列")

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

<p>&nbsp;</p>
<p><strong>Example 1:</strong></p>

<pre>
<strong>Input:</strong> arr = [1,2,3,4], difference = 1
<strong>Output:</strong> 4
<strong>Explanation: </strong>The longest arithmetic subsequence is [1,2,3,4].</pre>

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

<pre>
<strong>Input:</strong> arr = [1,3,5,7], difference = 1
<strong>Output:</strong> 1
<strong>Explanation: </strong>The longest arithmetic subsequence is any single element.
</pre>

<p><strong>Example 3:</strong></p>

<pre>
<strong>Input:</strong> arr = [1,5,7,8,5,3,4,2,1], difference = -2
<strong>Output:</strong> 4
<strong>Explanation: </strong>The longest arithmetic subsequence is [7,5,3,1].
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
<li><code>1 &lt;= arr.length &lt;= 10^5</code></li>
<li><code>-10^4 &lt;= arr[i], difference &lt;= 10^4</code></li>
</ul>
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

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

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

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

Expand Down
2 changes: 1 addition & 1 deletion problems/monthly-transactions-ii/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@

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

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


12 changes: 12 additions & 0 deletions problems/moving-average-from-data-stream/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,19 @@

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

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

<p><strong>Example:</strong></p>

<pre>
MovingAverage m = new MovingAverage(3);
m.next(1) = 1
m.next(10) = (1 + 10) / 2
m.next(3) = (1 + 10 + 3) / 3
m.next(5) = (10 + 3 + 5) / 3
</pre>

<p>&nbsp;</p>

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