Skip to content

Commit 7bb6e40

Browse files
author
Shuo
committed
A: new
1 parent 62f1dec commit 7bb6e40

File tree

516 files changed

+16976
-1914
lines changed

Some content is hidden

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

516 files changed

+16976
-1914
lines changed

README.md

+35-4
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,43 @@ LeetCode Problems' Solutions
7878

7979
| # | Title | Solution | Difficulty |
8080
| :-: | - | - | :-: |
81+
| <span id="1955">1955</span> | [Count Number of Special Subsequences](https://leetcode.com/problems/count-number-of-special-subsequences "统计特殊子序列的数目") | [Go](problems/count-number-of-special-subsequences) | Hard |
82+
| <span id="1954">1954</span> | [Minimum Garden Perimeter to Collect Enough Apples](https://leetcode.com/problems/minimum-garden-perimeter-to-collect-enough-apples "收集足够苹果的最小花园周长") | [Go](problems/minimum-garden-perimeter-to-collect-enough-apples) | Medium |
83+
| <span id="1953">1953</span> | [Maximum Number of Weeks for Which You Can Work](https://leetcode.com/problems/maximum-number-of-weeks-for-which-you-can-work "你可以工作的最大周数") | [Go](problems/maximum-number-of-weeks-for-which-you-can-work) | Medium |
84+
| <span id="1952">1952</span> | [Three Divisors](https://leetcode.com/problems/three-divisors "三除数") | [Go](problems/three-divisors) | Easy |
85+
| <span id="1951">1951</span> | [All the Pairs With the Maximum Number of Common Followers](https://leetcode.com/problems/all-the-pairs-with-the-maximum-number-of-common-followers) 🔒 | [MySQL](problems/all-the-pairs-with-the-maximum-number-of-common-followers) | Medium |
86+
| <span id="1950">1950</span> | [Maximum of Minimum Values in All Subarrays](https://leetcode.com/problems/maximum-of-minimum-values-in-all-subarrays "所有子数组最小值中的最大值") 🔒 | [Go](problems/maximum-of-minimum-values-in-all-subarrays) | Medium |
87+
| <span id="1949">1949</span> | [Strong Friendship](https://leetcode.com/problems/strong-friendship) 🔒 | [MySQL](problems/strong-friendship) | Medium |
88+
| <span id="1948">1948</span> | [Delete Duplicate Folders in System](https://leetcode.com/problems/delete-duplicate-folders-in-system "删除系统中的重复文件夹") | [Go](problems/delete-duplicate-folders-in-system) | Hard |
89+
| <span id="1947">1947</span> | [Maximum Compatibility Score Sum](https://leetcode.com/problems/maximum-compatibility-score-sum "最大兼容性评分和") | [Go](problems/maximum-compatibility-score-sum) | Medium |
90+
| <span id="1946">1946</span> | [Largest Number After Mutating Substring](https://leetcode.com/problems/largest-number-after-mutating-substring "子字符串突变后可能得到的最大整数") | [Go](problems/largest-number-after-mutating-substring) | Medium |
91+
| <span id="1945">1945</span> | [Sum of Digits of String After Convert](https://leetcode.com/problems/sum-of-digits-of-string-after-convert "字符串转化后的各位数字之和") | [Go](problems/sum-of-digits-of-string-after-convert) | Easy |
92+
| <span id="1944">1944</span> | [Number of Visible People in a Queue](https://leetcode.com/problems/number-of-visible-people-in-a-queue "队列中可以看到的人数") | [Go](problems/number-of-visible-people-in-a-queue) | Hard |
93+
| <span id="1943">1943</span> | [Describe the Painting](https://leetcode.com/problems/describe-the-painting "描述绘画结果") | [Go](problems/describe-the-painting) | Medium |
94+
| <span id="1942">1942</span> | [The Number of the Smallest Unoccupied Chair](https://leetcode.com/problems/the-number-of-the-smallest-unoccupied-chair "最小未被占据椅子的编号") | [Go](problems/the-number-of-the-smallest-unoccupied-chair) | Medium |
95+
| <span id="1941">1941</span> | [Check if All Characters Have Equal Number of Occurrences](https://leetcode.com/problems/check-if-all-characters-have-equal-number-of-occurrences "检查是否所有字符出现次数相同") | [Go](problems/check-if-all-characters-have-equal-number-of-occurrences) | Easy |
96+
| <span id="1940">1940</span> | [Longest Common Subsequence Between Sorted Arrays](https://leetcode.com/problems/longest-common-subsequence-between-sorted-arrays "排序数组之间的最长公共子序列") 🔒 | [Go](problems/longest-common-subsequence-between-sorted-arrays) | Medium |
97+
| <span id="1939">1939</span> | [Users That Actively Request Confirmation Messages](https://leetcode.com/problems/users-that-actively-request-confirmation-messages) 🔒 | [MySQL](problems/users-that-actively-request-confirmation-messages) | Easy |
98+
| <span id="1938">1938</span> | [Maximum Genetic Difference Query](https://leetcode.com/problems/maximum-genetic-difference-query "查询最大基因差") | [Go](problems/maximum-genetic-difference-query) | Hard |
99+
| <span id="1937">1937</span> | [Maximum Number of Points with Cost](https://leetcode.com/problems/maximum-number-of-points-with-cost "扣分后的最大得分") | [Go](problems/maximum-number-of-points-with-cost) | Medium |
100+
| <span id="1936">1936</span> | [Add Minimum Number of Rungs](https://leetcode.com/problems/add-minimum-number-of-rungs "新增的最少台阶数") | [Go](problems/add-minimum-number-of-rungs) | Medium |
101+
| <span id="1935">1935</span> | [Maximum Number of Words You Can Type](https://leetcode.com/problems/maximum-number-of-words-you-can-type "可以输入的最大单词数") | [Go](problems/maximum-number-of-words-you-can-type) | Easy |
102+
| <span id="1934">1934</span> | [Confirmation Rate](https://leetcode.com/problems/confirmation-rate) 🔒 | [MySQL](problems/confirmation-rate) | Medium |
103+
| <span id="1933">1933</span> | [Check if String Is Decomposable Into Value-Equal Substrings](https://leetcode.com/problems/check-if-string-is-decomposable-into-value-equal-substrings "判断字符串是否可分解为值均等的子串") 🔒 | [Go](problems/check-if-string-is-decomposable-into-value-equal-substrings) | Easy |
104+
| <span id="1932">1932</span> | [Merge BSTs to Create Single BST](https://leetcode.com/problems/merge-bsts-to-create-single-bst "合并多棵二叉搜索树") | [Go](problems/merge-bsts-to-create-single-bst) | Hard |
105+
| <span id="1931">1931</span> | [Painting a Grid With Three Different Colors](https://leetcode.com/problems/painting-a-grid-with-three-different-colors "用三种不同颜色为网格涂色") | [Go](problems/painting-a-grid-with-three-different-colors) | Hard |
106+
| <span id="1930">1930</span> | [Unique Length-3 Palindromic Subsequences](https://leetcode.com/problems/unique-length-3-palindromic-subsequences "长度为 3 的不同回文子序列") | [Go](problems/unique-length-3-palindromic-subsequences) | Medium |
107+
| <span id="1929">1929</span> | [Concatenation of Array](https://leetcode.com/problems/concatenation-of-array "数组串联") | [Go](problems/concatenation-of-array) | Easy |
108+
| <span id="1928">1928</span> | [Minimum Cost to Reach Destination in Time](https://leetcode.com/problems/minimum-cost-to-reach-destination-in-time "规定时间内到达终点的最小花费") | [Go](problems/minimum-cost-to-reach-destination-in-time) | Hard |
109+
| <span id="1927">1927</span> | [Sum Game](https://leetcode.com/problems/sum-game "求和游戏") | [Go](problems/sum-game) | Medium |
110+
| <span id="1926">1926</span> | [Nearest Exit from Entrance in Maze](https://leetcode.com/problems/nearest-exit-from-entrance-in-maze "迷宫中离入口最近的出口") | [Go](problems/nearest-exit-from-entrance-in-maze) | Medium |
111+
| <span id="1925">1925</span> | [Count Square Sum Triples](https://leetcode.com/problems/count-square-sum-triples "统计平方和三元组的数目") | [Go](problems/count-square-sum-triples) | Easy |
81112
| <span id="1924">1924</span> | [Erect the Fence II](https://leetcode.com/problems/erect-the-fence-ii) 🔒 | [Go](problems/erect-the-fence-ii) | Hard |
82113
| <span id="1923">1923</span> | [Longest Common Subpath](https://leetcode.com/problems/longest-common-subpath "最长公共子路径") | [Go](problems/longest-common-subpath) | Hard |
83114
| <span id="1922">1922</span> | [Count Good Numbers](https://leetcode.com/problems/count-good-numbers "统计好数字的数目") | [Go](problems/count-good-numbers) | Medium |
84115
| <span id="1921">1921</span> | [Eliminate Maximum Number of Monsters](https://leetcode.com/problems/eliminate-maximum-number-of-monsters "消灭怪物的最大数量") | [Go](problems/eliminate-maximum-number-of-monsters) | Medium |
85116
| <span id="1920">1920</span> | [Build Array from Permutation](https://leetcode.com/problems/build-array-from-permutation "基于排列构建数组") | [Go](problems/build-array-from-permutation) | Easy |
86-
| <span id="1919">1919</span> | [Leetcodify Similar Friends](https://leetcode.com/problems/leetcodify-similar-friends) 🔒 | [MySQL](problems/leetcodify-similar-friends) | Hard |
117+
| <span id="1919">1919</span> | [Leetcodify Similar Friends](https://leetcode.com/problems/leetcodify-similar-friends "兴趣相同的朋友") 🔒 | [MySQL](problems/leetcodify-similar-friends) | Hard |
87118
| <span id="1918">1918</span> | [Kth Smallest Subarray Sum](https://leetcode.com/problems/kth-smallest-subarray-sum) 🔒 | [Go](problems/kth-smallest-subarray-sum) | Medium |
88119
| <span id="1917">1917</span> | [Leetcodify Friends Recommendations](https://leetcode.com/problems/leetcodify-friends-recommendations) 🔒 | [MySQL](problems/leetcodify-friends-recommendations) | Hard |
89120
| <span id="1916">1916</span> | [Count Ways to Build Rooms in an Ant Colony](https://leetcode.com/problems/count-ways-to-build-rooms-in-an-ant-colony "统计为蚁群构筑房间的不同顺序") | [Go](problems/count-ways-to-build-rooms-in-an-ant-colony) | Hard |
@@ -161,7 +192,7 @@ LeetCode Problems' Solutions
161192
| <span id="1844">1844</span> | [Replace All Digits with Characters](https://leetcode.com/problems/replace-all-digits-with-characters "将所有数字用字符替换") | [Go](problems/replace-all-digits-with-characters) | Easy |
162193
| <span id="1843">1843</span> | [Suspicious Bank Accounts](https://leetcode.com/problems/suspicious-bank-accounts) 🔒 | [MySQL](problems/suspicious-bank-accounts) | Medium |
163194
| <span id="1842">1842</span> | [Next Palindrome Using Same Digits](https://leetcode.com/problems/next-palindrome-using-same-digits "下个由相同数字构成的回文串") 🔒 | [Go](problems/next-palindrome-using-same-digits) | Hard |
164-
| <span id="1841">1841</span> | [League Statistics](https://leetcode.com/problems/league-statistics) 🔒 | [MySQL](problems/league-statistics) | Medium |
195+
| <span id="1841">1841</span> | [League Statistics](https://leetcode.com/problems/league-statistics "联赛信息统计") 🔒 | [MySQL](problems/league-statistics) | Medium |
165196
| <span id="1840">1840</span> | [Maximum Building Height](https://leetcode.com/problems/maximum-building-height "最高建筑高度") | [Go](problems/maximum-building-height) | Hard |
166197
| <span id="1839">1839</span> | [Longest Substring Of All Vowels in Order](https://leetcode.com/problems/longest-substring-of-all-vowels-in-order "所有元音按顺序排布的最长子字符串") | [Go](problems/longest-substring-of-all-vowels-in-order) | Medium |
167198
| <span id="1838">1838</span> | [Frequency of the Most Frequent Element](https://leetcode.com/problems/frequency-of-the-most-frequent-element "最高频元素的频数") | [Go](problems/frequency-of-the-most-frequent-element) | Medium |
@@ -192,7 +223,7 @@ LeetCode Problems' Solutions
192223
| <span id="1813">1813</span> | [Sentence Similarity III](https://leetcode.com/problems/sentence-similarity-iii "句子相似性 III") | [Go](problems/sentence-similarity-iii) | Medium |
193224
| <span id="1812">1812</span> | [Determine Color of a Chessboard Square](https://leetcode.com/problems/determine-color-of-a-chessboard-square "判断国际象棋棋盘中一个格子的颜色") | [Go](problems/determine-color-of-a-chessboard-square) | Easy |
194225
| <span id="1811">1811</span> | [Find Interview Candidates](https://leetcode.com/problems/find-interview-candidates "寻找面试候选人") 🔒 | [MySQL](problems/find-interview-candidates) | Medium |
195-
| <span id="1810">1810</span> | [Minimum Path Cost in a Hidden Grid](https://leetcode.com/problems/minimum-path-cost-in-a-hidden-grid) 🔒 | [Go](problems/minimum-path-cost-in-a-hidden-grid) | Medium |
226+
| <span id="1810">1810</span> | [Minimum Path Cost in a Hidden Grid](https://leetcode.com/problems/minimum-path-cost-in-a-hidden-grid "隐藏网格下的最小消耗路径") 🔒 | [Go](problems/minimum-path-cost-in-a-hidden-grid) | Medium |
196227
| <span id="1809">1809</span> | [Ad-Free Sessions](https://leetcode.com/problems/ad-free-sessions "没有广告的剧集") 🔒 | [MySQL](problems/ad-free-sessions) | Easy |
197228
| <span id="1808">1808</span> | [Maximize Number of Nice Divisors](https://leetcode.com/problems/maximize-number-of-nice-divisors "好因子的最大数目") | [Go](problems/maximize-number-of-nice-divisors) | Hard |
198229
| <span id="1807">1807</span> | [Evaluate the Bracket Pairs of a String](https://leetcode.com/problems/evaluate-the-bracket-pairs-of-a-string "替换字符串中的括号内容") | [Go](problems/evaluate-the-bracket-pairs-of-a-string) | Medium |
@@ -224,7 +255,7 @@ LeetCode Problems' Solutions
224255
| <span id="1781">1781</span> | [Sum of Beauty of All Substrings](https://leetcode.com/problems/sum-of-beauty-of-all-substrings "所有子字符串美丽值之和") | [Go](problems/sum-of-beauty-of-all-substrings) | Medium |
225256
| <span id="1780">1780</span> | [Check if Number is a Sum of Powers of Three](https://leetcode.com/problems/check-if-number-is-a-sum-of-powers-of-three "判断一个数字是否可以表示成三的幂的和") | [Go](problems/check-if-number-is-a-sum-of-powers-of-three) | Medium |
226257
| <span id="1779">1779</span> | [Find Nearest Point That Has the Same X or Y Coordinate](https://leetcode.com/problems/find-nearest-point-that-has-the-same-x-or-y-coordinate "找到最近的有相同 X 或 Y 坐标的点") | [Go](problems/find-nearest-point-that-has-the-same-x-or-y-coordinate) | Easy |
227-
| <span id="1778">1778</span> | [Shortest Path in a Hidden Grid](https://leetcode.com/problems/shortest-path-in-a-hidden-grid) 🔒 | [Go](problems/shortest-path-in-a-hidden-grid) | Medium |
258+
| <span id="1778">1778</span> | [Shortest Path in a Hidden Grid](https://leetcode.com/problems/shortest-path-in-a-hidden-grid "未知网格中的最短路径") 🔒 | [Go](problems/shortest-path-in-a-hidden-grid) | Medium |
228259
| <span id="1777">1777</span> | [Product's Price for Each Store](https://leetcode.com/problems/products-price-for-each-store "每家商店的产品价格") 🔒 | [MySQL](problems/products-price-for-each-store) | Easy |
229260
| <span id="1776">1776</span> | [Car Fleet II](https://leetcode.com/problems/car-fleet-ii "车队 II") | [Go](problems/car-fleet-ii) | Hard |
230261
| <span id="1775">1775</span> | [Equal Sum Arrays With Minimum Number of Operations](https://leetcode.com/problems/equal-sum-arrays-with-minimum-number-of-operations "通过最少操作次数使数组的和相等") | [Go](problems/equal-sum-arrays-with-minimum-number-of-operations) | Medium |

problems/3sum-smaller/README.md

+12
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,19 @@
1111

1212
## [259. 3Sum Smaller (Medium)](https://leetcode.com/problems/3sum-smaller "较小的三数之和")
1313

14+
<p>Given an array of <i>n</i> integers <i>nums</i> and a <i>target</i>, find the number of index triplets <code>i, j, k</code> with <code>0 &lt;= i &lt; j &lt; k &lt; n</code> that satisfy the condition <code>nums[i] + nums[j] + nums[k] &lt; target</code>.</p>
1415

16+
<p><strong>Example:</strong></p>
17+
18+
<pre>
19+
<strong>Input:</strong> <i>nums</i> = <code>[-2,0,1,3]</code>, and <i>target</i> = 2
20+
<strong>Output:</strong> 2
21+
<strong>Explanation:</strong>&nbsp;Because there are two triplets which sums are less than 2:
22+
&nbsp; [-2,0,1]
23+
[-2,0,3]
24+
</pre>
25+
26+
<p><b style="font-family: sans-serif, Arial, Verdana, &quot;Trebuchet MS&quot;;">Follow up:</b> Could you solve it in <i>O</i>(<i>n</i><sup>2</sup>) runtime?</p>
1527

1628
### Related Topics
1729
[[Array](../../tag/array/README.md)]

problems/4-keys-keyboard/README.md

+34
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,42 @@
1111

1212
## [651. 4 Keys Keyboard (Medium)](https://leetcode.com/problems/4-keys-keyboard "4键键盘")
1313

14+
<p>Imagine you have a special keyboard with the following keys: </p>
15+
<p><code>Key 1: (A)</code>: Print one 'A' on screen.</p>
16+
<p><code>Key 2: (Ctrl-A)</code>: Select the whole screen.</p>
17+
<p><code>Key 3: (Ctrl-C)</code>: Copy selection to buffer.</p>
18+
<p><code>Key 4: (Ctrl-V)</code>: Print buffer on screen appending it after what has already been printed. </p>
1419

1520

21+
22+
<p>Now, you can only press the keyboard for <b>N</b> times (with the above four keys), find out the maximum numbers of 'A' you can print on screen.</p>
23+
24+
25+
<p><b>Example 1:</b><br />
26+
<pre><b>Input:</b> N = 3
27+
<b>Output:</b> 3
28+
<b>Explanation:</b>
29+
We can at most get 3 A's on screen by pressing following key sequence:
30+
A, A, A
31+
</pre>
32+
</p>
33+
34+
<p><b>Example 2:</b><br />
35+
<pre><b>Input:</b> N = 7
36+
<b>Output:</b> 9
37+
<b>Explanation:</b>
38+
We can at most get 9 A's on screen by pressing following key sequence:
39+
A, A, A, Ctrl A, Ctrl C, Ctrl V, Ctrl V
40+
</pre>
41+
</p>
42+
43+
<p><b>Note:</b><br>
44+
<ol>
45+
<li>1 <= N <= 50 </li>
46+
<li>Answers will be in the range of 32-bit signed integer.</li>
47+
</ol>
48+
</p>
49+
1650
### Related Topics
1751
[[Math](../../tag/math/README.md)]
1852
[[Dynamic Programming](../../tag/dynamic-programming/README.md)]

problems/active-businesses/README.md

+42
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,49 @@
1111

1212
## [1126. Active Businesses (Medium)](https://leetcode.com/problems/active-businesses "查询活跃业务")
1313

14+
<p>Table: <code>Events</code></p>
1415

16+
<pre>
17+
+---------------+---------+
18+
| Column Name | Type |
19+
+---------------+---------+
20+
| business_id | int |
21+
| event_type | varchar |
22+
| occurences | int |
23+
+---------------+---------+
24+
(business_id, event_type) is the primary key of this table.
25+
Each row in the table logs the info that an event of some type occured at some business for a number of times.</pre>
26+
27+
<p>&nbsp;</p>
28+
29+
<p>Write an SQL query to find all <em>active businesses</em>.</p>
30+
31+
<p>An active business is a business that has more than one event type&nbsp;with occurences greater than the average occurences of that event type&nbsp;among all businesses.</p>
32+
33+
<p>The query result format is in the following example:</p>
34+
35+
<pre>
36+
Events table:
37+
+-------------+------------+------------+
38+
| business_id | event_type | occurences |
39+
+-------------+------------+------------+
40+
| 1 | reviews | 7 |
41+
| 3 | reviews | 3 |
42+
| 1 | ads | 11 |
43+
| 2 | ads | 7 |
44+
| 3 | ads | 6 |
45+
| 1 | page views | 3 |
46+
| 2 | page views | 12 |
47+
+-------------+------------+------------+
48+
49+
Result table:
50+
+-------------+
51+
| business_id |
52+
+-------------+
53+
| 1 |
54+
+-------------+
55+
Average for &#39;reviews&#39;, &#39;ads&#39; and &#39;page views&#39; are (7+3)/2=5, (11+7+6)/3=8, (3+12)/2=7.5 respectively.
56+
Business with id 1 has 7 &#39;reviews&#39; events (more than 5) and 11 &#39;ads&#39; events (more than 8) so it is an active business.</pre>
1557

1658
### Related Topics
1759
[[Database](../../tag/database/README.md)]

0 commit comments

Comments
 (0)