Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 68937aa

Browse files
author
Shuo
authored
Merge pull request #835 from openset/develop
A: new
2 parents 6cdb14b + 0241653 commit 68937aa

File tree

175 files changed

+3230
-1680
lines changed

Some content is hidden

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

175 files changed

+3230
-1680
lines changed

‎README.md

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,27 @@ LeetCode Problems' Solutions
7878

7979
| # | Title | Solution | Difficulty |
8080
| :-: | - | - | :-: |
81+
| <span id="1840">1840</span> | [Maximum Building Height](https://leetcode.com/problems/maximum-building-height "最高建筑高度") | [Go](problems/maximum-building-height) | Hard |
82+
| <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 |
83+
| <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 |
84+
| <span id="1837">1837</span> | [Sum of Digits in Base K](https://leetcode.com/problems/sum-of-digits-in-base-k "K 进制表示下的各位数字总和") | [Go](problems/sum-of-digits-in-base-k) | Easy |
85+
| <span id="1836">1836</span> | [Remove Duplicates From an Unsorted Linked List](https://leetcode.com/problems/remove-duplicates-from-an-unsorted-linked-list) 🔒 | [Go](problems/remove-duplicates-from-an-unsorted-linked-list) | Medium |
86+
| <span id="1835">1835</span> | [Find XOR Sum of All Pairs Bitwise AND](https://leetcode.com/problems/find-xor-sum-of-all-pairs-bitwise-and "所有数对按位与结果的异或和") | [Go](problems/find-xor-sum-of-all-pairs-bitwise-and) | Hard |
87+
| <span id="1834">1834</span> | [Single-Threaded CPU](https://leetcode.com/problems/single-threaded-cpu "单线程 CPU") | [Go](problems/single-threaded-cpu) | Medium |
88+
| <span id="1833">1833</span> | [Maximum Ice Cream Bars](https://leetcode.com/problems/maximum-ice-cream-bars "雪糕的最大数量") | [Go](problems/maximum-ice-cream-bars) | Medium |
89+
| <span id="1832">1832</span> | [Check if the Sentence Is Pangram](https://leetcode.com/problems/check-if-the-sentence-is-pangram "判断句子是否为全字母句") | [Go](problems/check-if-the-sentence-is-pangram) | Easy |
90+
| <span id="1831">1831</span> | [Maximum Transaction Each Day](https://leetcode.com/problems/maximum-transaction-each-day) 🔒 | [MySQL](problems/maximum-transaction-each-day) | Medium |
91+
| <span id="1830">1830</span> | [Minimum Number of Operations to Make String Sorted](https://leetcode.com/problems/minimum-number-of-operations-to-make-string-sorted "使字符串有序的最少操作次数") | [Go](problems/minimum-number-of-operations-to-make-string-sorted) | Hard |
92+
| <span id="1829">1829</span> | [Maximum XOR for Each Query](https://leetcode.com/problems/maximum-xor-for-each-query "每个查询的最大异或值") | [Go](problems/maximum-xor-for-each-query) | Medium |
93+
| <span id="1828">1828</span> | [Queries on Number of Points Inside a Circle](https://leetcode.com/problems/queries-on-number-of-points-inside-a-circle "统计一个圆中点的数目") | [Go](problems/queries-on-number-of-points-inside-a-circle) | Medium |
94+
| <span id="1827">1827</span> | [Minimum Operations to Make the Array Increasing](https://leetcode.com/problems/minimum-operations-to-make-the-array-increasing "最少操作使数组递增") | [Go](problems/minimum-operations-to-make-the-array-increasing) | Easy |
95+
| <span id="1826">1826</span> | [Faulty Sensor](https://leetcode.com/problems/faulty-sensor) 🔒 | [Go](problems/faulty-sensor) | Easy |
96+
| <span id="1825">1825</span> | [Finding MK Average](https://leetcode.com/problems/finding-mk-average "求出 MK 平均值") | [Go](problems/finding-mk-average) | Hard |
97+
| <span id="1824">1824</span> | [Minimum Sideway Jumps](https://leetcode.com/problems/minimum-sideway-jumps "最少侧跳次数") | [Go](problems/minimum-sideway-jumps) | Medium |
98+
| <span id="1823">1823</span> | [Find the Winner of the Circular Game](https://leetcode.com/problems/find-the-winner-of-the-circular-game "找出游戏的获胜者") | [Go](problems/find-the-winner-of-the-circular-game) | Medium |
99+
| <span id="1822">1822</span> | [Sign of the Product of an Array](https://leetcode.com/problems/sign-of-the-product-of-an-array "数组元素积的符号") | [Go](problems/sign-of-the-product-of-an-array) | Easy |
100+
| <span id="1821">1821</span> | [Find Customers With Positive Revenue this Year](https://leetcode.com/problems/find-customers-with-positive-revenue-this-year) 🔒 | [MySQL](problems/find-customers-with-positive-revenue-this-year) | Easy |
101+
| <span id="1820">1820</span> | [Maximum Number of Accepted Invitations](https://leetcode.com/problems/maximum-number-of-accepted-invitations) 🔒 | [Go](problems/maximum-number-of-accepted-invitations) | Medium |
81102
| <span id="1819">1819</span> | [Number of Different Subsequences GCDs](https://leetcode.com/problems/number-of-different-subsequences-gcds "序列中不同最大公约数的数目") | [Go](problems/number-of-different-subsequences-gcds) | Hard |
82103
| <span id="1818">1818</span> | [Minimum Absolute Sum Difference](https://leetcode.com/problems/minimum-absolute-sum-difference "绝对差值和") | [Go](problems/minimum-absolute-sum-difference) | Medium |
83104
| <span id="1817">1817</span> | [Finding the Users Active Minutes](https://leetcode.com/problems/finding-the-users-active-minutes "查找用户活跃分钟数") | [Go](problems/finding-the-users-active-minutes) | Medium |
@@ -93,7 +114,7 @@ LeetCode Problems' Solutions
93114
| <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 |
94115
| <span id="1806">1806</span> | [Minimum Number of Operations to Reinitialize a Permutation](https://leetcode.com/problems/minimum-number-of-operations-to-reinitialize-a-permutation "还原排列的最少操作步数") | [Go](problems/minimum-number-of-operations-to-reinitialize-a-permutation) | Medium |
95116
| <span id="1805">1805</span> | [Number of Different Integers in a String](https://leetcode.com/problems/number-of-different-integers-in-a-string "字符串中不同整数的数目") | [Go](problems/number-of-different-integers-in-a-string) | Easy |
96-
| <span id="1804">1804</span> | [Implement Trie II (Prefix Tree)](https://leetcode.com/problems/implement-trie-ii-prefix-tree) 🔒 | [Go](problems/implement-trie-ii-prefix-tree) | Medium |
117+
| <span id="1804">1804</span> | [Implement Trie II (Prefix Tree)](https://leetcode.com/problems/implement-trie-ii-prefix-tree"实现 Trie (前缀树) II") 🔒 | [Go](problems/implement-trie-ii-prefix-tree) | Medium |
97118
| <span id="1803">1803</span> | [Count Pairs With XOR in a Range](https://leetcode.com/problems/count-pairs-with-xor-in-a-range "统计异或值在范围内的数对有多少") | [Go](problems/count-pairs-with-xor-in-a-range) | Hard |
98119
| <span id="1802">1802</span> | [Maximum Value at a Given Index in a Bounded Array](https://leetcode.com/problems/maximum-value-at-a-given-index-in-a-bounded-array "有界数组中指定下标处的最大值") | [Go](problems/maximum-value-at-a-given-index-in-a-bounded-array) | Medium |
99120
| <span id="1801">1801</span> | [Number of Orders in the Backlog](https://leetcode.com/problems/number-of-orders-in-the-backlog "积压订单中的订单总数") | [Go](problems/number-of-orders-in-the-backlog) | Medium |
@@ -114,7 +135,7 @@ LeetCode Problems' Solutions
114135
| <span id="1786">1786</span> | [Number of Restricted Paths From First to Last Node](https://leetcode.com/problems/number-of-restricted-paths-from-first-to-last-node "从第一个节点出发到最后一个节点的受限路径数") | [Go](problems/number-of-restricted-paths-from-first-to-last-node) | Medium |
115136
| <span id="1785">1785</span> | [Minimum Elements to Add to Form a Given Sum](https://leetcode.com/problems/minimum-elements-to-add-to-form-a-given-sum "构成特定和需要添加的最少元素") | [Go](problems/minimum-elements-to-add-to-form-a-given-sum) | Medium |
116137
| <span id="1784">1784</span> | [Check if Binary String Has at Most One Segment of Ones](https://leetcode.com/problems/check-if-binary-string-has-at-most-one-segment-of-ones "检查二进制字符串字段") | [Go](problems/check-if-binary-string-has-at-most-one-segment-of-ones) | Easy |
117-
| <span id="1783">1783</span> | [Grand Slam Titles](https://leetcode.com/problems/grand-slam-titles) 🔒 | [MySQL](problems/grand-slam-titles) | Medium |
138+
| <span id="1783">1783</span> | [Grand Slam Titles](https://leetcode.com/problems/grand-slam-titles"大满贯数量") 🔒 | [MySQL](problems/grand-slam-titles) | Medium |
118139
| <span id="1782">1782</span> | [Count Pairs Of Nodes](https://leetcode.com/problems/count-pairs-of-nodes "统计点对的数目") | [Go](problems/count-pairs-of-nodes) | Hard |
119140
| <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 |
120141
| <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 |
@@ -150,13 +171,13 @@ LeetCode Problems' Solutions
150171
| <span id="1750">1750</span> | [Minimum Length of String After Deleting Similar Ends](https://leetcode.com/problems/minimum-length-of-string-after-deleting-similar-ends "删除字符串两端相同字符后的最短长度") | [Go](problems/minimum-length-of-string-after-deleting-similar-ends) | Medium |
151172
| <span id="1749">1749</span> | [Maximum Absolute Sum of Any Subarray](https://leetcode.com/problems/maximum-absolute-sum-of-any-subarray "任意子数组和的绝对值的最大值") | [Go](problems/maximum-absolute-sum-of-any-subarray) | Medium |
152173
| <span id="1748">1748</span> | [Sum of Unique Elements](https://leetcode.com/problems/sum-of-unique-elements "唯一元素的和") | [Go](problems/sum-of-unique-elements) | Easy |
153-
| <span id="1747">1747</span> | [Leetflex Banned Accounts](https://leetcode.com/problems/leetflex-banned-accounts) 🔒 | [MySQL](problems/leetflex-banned-accounts) | Medium |
154-
| <span id="1746">1746</span> | [Maximum Subarray Sum After One Operation](https://leetcode.com/problems/maximum-subarray-sum-after-one-operation) 🔒 | [Go](problems/maximum-subarray-sum-after-one-operation) | Medium |
174+
| <span id="1747">1747</span> | [Leetflex Banned Accounts](https://leetcode.com/problems/leetflex-banned-accounts"应该被禁止的Leetflex账户") 🔒 | [MySQL](problems/leetflex-banned-accounts) | Medium |
175+
| <span id="1746">1746</span> | [Maximum Subarray Sum After One Operation](https://leetcode.com/problems/maximum-subarray-sum-after-one-operation"经过一次操作后的最大子数组和") 🔒 | [Go](problems/maximum-subarray-sum-after-one-operation) | Medium |
155176
| <span id="1745">1745</span> | [Palindrome Partitioning IV](https://leetcode.com/problems/palindrome-partitioning-iv "回文串分割 IV") | [Go](problems/palindrome-partitioning-iv) | Hard |
156177
| <span id="1744">1744</span> | [Can You Eat Your Favorite Candy on Your Favorite Day?](https://leetcode.com/problems/can-you-eat-your-favorite-candy-on-your-favorite-day "你能在你最喜欢的那天吃到你最喜欢的糖果吗?") | [Go](problems/can-you-eat-your-favorite-candy-on-your-favorite-day) | Medium |
157178
| <span id="1743">1743</span> | [Restore the Array From Adjacent Pairs](https://leetcode.com/problems/restore-the-array-from-adjacent-pairs "从相邻元素对还原数组") | [Go](problems/restore-the-array-from-adjacent-pairs) | Medium |
158179
| <span id="1742">1742</span> | [Maximum Number of Balls in a Box](https://leetcode.com/problems/maximum-number-of-balls-in-a-box "盒子中小球的最大数量") | [Go](problems/maximum-number-of-balls-in-a-box) | Easy |
159-
| <span id="1741">1741</span> | [Find Total Time Spent by Each Employee](https://leetcode.com/problems/find-total-time-spent-by-each-employee) 🔒 | [MySQL](problems/find-total-time-spent-by-each-employee) | Easy |
180+
| <span id="1741">1741</span> | [Find Total Time Spent by Each Employee](https://leetcode.com/problems/find-total-time-spent-by-each-employee"查找每个员工花费的总时间") 🔒 | [MySQL](problems/find-total-time-spent-by-each-employee) | Easy |
160181
| <span id="1740">1740</span> | [Find Distance in a Binary Tree](https://leetcode.com/problems/find-distance-in-a-binary-tree "找到二叉树中的距离") 🔒 | [Go](problems/find-distance-in-a-binary-tree) | Medium |
161182
| <span id="1739">1739</span> | [Building Boxes](https://leetcode.com/problems/building-boxes "放置盒子") | [Go](problems/building-boxes) | Hard |
162183
| <span id="1738">1738</span> | [Find Kth Largest XOR Coordinate Value](https://leetcode.com/problems/find-kth-largest-xor-coordinate-value "找出第 K 大的异或坐标值") | [Go](problems/find-kth-largest-xor-coordinate-value) | Medium |
@@ -166,7 +187,7 @@ LeetCode Problems' Solutions
166187
| <span id="1734">1734</span> | [Decode XORed Permutation](https://leetcode.com/problems/decode-xored-permutation "解码异或后的排列") | [Go](problems/decode-xored-permutation) | Medium |
167188
| <span id="1733">1733</span> | [Minimum Number of People to Teach](https://leetcode.com/problems/minimum-number-of-people-to-teach "需要教语言的最少人数") | [Go](problems/minimum-number-of-people-to-teach) | Medium |
168189
| <span id="1732">1732</span> | [Find the Highest Altitude](https://leetcode.com/problems/find-the-highest-altitude "找到最高海拔") | [Go](problems/find-the-highest-altitude) | Easy |
169-
| <span id="1731">1731</span> | [The Number of Employees Which Report to Each Employee](https://leetcode.com/problems/the-number-of-employees-which-report-to-each-employee) 🔒 | [MySQL](problems/the-number-of-employees-which-report-to-each-employee) | Easy |
190+
| <span id="1731">1731</span> | [The Number of Employees Which Report to Each Employee](https://leetcode.com/problems/the-number-of-employees-which-report-to-each-employee"每位经理的下属员工数量") 🔒 | [MySQL](problems/the-number-of-employees-which-report-to-each-employee) | Easy |
170191
| <span id="1730">1730</span> | [Shortest Path to Get Food](https://leetcode.com/problems/shortest-path-to-get-food "获取食物的最短路径") 🔒 | [Go](problems/shortest-path-to-get-food) | Medium |
171192
| <span id="1729">1729</span> | [Find Followers Count](https://leetcode.com/problems/find-followers-count "求关注者的数量") 🔒 | [MySQL](problems/find-followers-count) | Easy |
172193
| <span id="1728">1728</span> | [Cat and Mouse II](https://leetcode.com/problems/cat-and-mouse-ii "猫和老鼠 II") | [Go](problems/cat-and-mouse-ii) | Hard |

‎problems/01-matrix/README.md

Lines changed: 20 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -11,49 +11,36 @@
1111

1212
## [542. 01 Matrix (Medium)](https://leetcode.com/problems/01-matrix "01 矩阵")
1313

14-
<p>Given a matrix consists of 0 and 1, find the distance of the nearest 0 for each cell.</p>
14+
<p>Given an <code>m x n</code> binary matrix <code>mat</code>, return <em>the distance of the nearest </em><code>0</code><em> for each cell</em>.</p>
1515

16-
<p>The distance between two adjacent cells is 1.</p>
16+
<p>The distance between two adjacent cells is <code>1</code>.</p>
1717

1818
<p>&nbsp;</p>
19-
20-
<p><b>Example 1: </b></p>
21-
19+
<p><strong>Example 1:</strong></p>
20+
<img alt="" src="https://assets.leetcode.com/uploads/2021/04/24/01-1-grid.jpg" style="width: 253px; height: 253px;" />
2221
<pre>
23-
<strong>Input:</strong>
24-
[[0,0,0],
25-
[0,1,0],
26-
[0,0,0]]
27-
28-
<strong>Output:</strong>
29-
[[0,0,0],
30-
&nbsp;[0,1,0],
31-
&nbsp;[0,0,0]]
22+
<strong>Input:</strong> mat = [[0,0,0],[0,1,0],[0,0,0]]
23+
<strong>Output:</strong> [[0,0,0],[0,1,0],[0,0,0]]
3224
</pre>
3325

34-
<p><b>Example 2: </b></p>
35-
26+
<p><strong>Example 2:</strong></p>
27+
<imgalt=""src="https://assets.leetcode.com/uploads/2021/04/24/01-2-grid.jpg"style="width: 253px; height: 253px;" />
3628
<pre>
37-
<b>Input:</b>
38-
[[0,0,0],
39-
[0,1,0],
40-
[1,1,1]]
41-
42-
<strong>Output:</strong>
43-
[[0,0,0],
44-
[0,1,0],
45-
[1,2,1]]
29+
<strong>Input:</strong> mat = [[0,0,0],[0,1,0],[1,1,1]]
30+
<strong>Output:</strong> [[0,0,0],[0,1,0],[1,2,1]]
4631
</pre>
4732

4833
<p>&nbsp;</p>
49-
50-
<p><b>Note:</b></p>
51-
52-
<ol>
53-
<li>The number of elements of the given matrix will not exceed 10,000.</li>
54-
<li>There are at least one 0 in the given matrix.</li>
55-
<li>The cells are adjacent in only four directions: up, down, left and right.</li>
56-
</ol>
34+
<p><strong>Constraints:</strong></p>
35+
36+
<ul>
37+
<li><code>m == mat.length</code></li>
38+
<li><code>n == mat[i].length</code></li>
39+
<li><code>1 &lt;= m, n &lt;= 10<sup>4</sup></code></li>
40+
<li><code>1 &lt;= m * n &lt;= 10<sup>4</sup></code></li>
41+
<li><code>mat[i][j]</code> is either <code>0</code> or <code>1</code>.</li>
42+
<li>There is at least one <code>0</code> in <code>mat</code>.</li>
43+
</ul>
5744

5845
### Related Topics
5946
[[Depth-first Search](../../tag/depth-first-search/README.md)]

‎problems/4sum-ii/README.md

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,29 +11,43 @@
1111

1212
## [454. 4Sum II (Medium)](https://leetcode.com/problems/4sum-ii "四数相加 II")
1313

14-
<p>Given four lists A, B, C, D of integer values, compute how many tuples <code>(i, j, k, l)</code> there are such that <code>A[i] + B[j] + C[k] + D[l]</code> is zero.</p>
14+
<p>Given four integer arrays <code>nums1</code>, <code>nums2</code>, <code>nums3</code>, and <code>nums4</code> all of length <code>n</code>, return the number of tuples <code>(i, j, k, l)</code> such that:</p>
1515

16-
<p>To make problem a bit easier, all A, B, C, D have same length of N where 0 &le; N &le; 500. All integers are in the range of -2<sup>28</sup> to 2<sup>28</sup> - 1 and the result is guaranteed to be at most 2<sup>31</sup> - 1.</p>
16+
<ul>
17+
<li><code>0 &lt;= i, j, k, l &lt; n</code></li>
18+
<li><code>nums1[i] + nums2[j] + nums3[k] + nums[l] == 0</code></li>
19+
</ul>
1720

18-
<p><b>Example:</b></p>
21+
<p>&nbsp;</p>
22+
<p><strong>Example 1:</strong></p>
1923

2024
<pre>
21-
<b>Input:</b>
22-
A = [ 1, 2]
23-
B = [-2,-1]
24-
C = [-1, 2]
25-
D = [ 0, 2]
25+
<strong>Input:</strong> nums1 = [1,2], nums2 = [-2,-1], nums3 = [-1,2], nums4 = [0,2]
26+
<strong>Output:</strong> 2
27+
<strong>Explanation:</strong>
28+
The two tuples are:
29+
1. (0, 0, 0, 1) -&gt; nums1[0] + nums2[0] + nums3[0] + nums4[1] = 1 + (-2) + (-1) + 2 = 0
30+
2. (1, 1, 0, 0) -&gt; nums1[1] + nums2[1] + nums3[0] + nums4[0] = 2 + (-1) + (-1) + 0 = 0
31+
</pre>
2632

27-
<b>Output:</b>
28-
2
33+
<p><strong>Example 2:</strong></p>
2934

30-
<b>Explanation:</b>
31-
The two tuples are:
32-
1. (0, 0, 0, 1) -&gt; A[0] + B[0] + C[0] + D[1] = 1 + (-2) + (-1) + 2 = 0
33-
2. (1, 1, 0, 0) -&gt; A[1] + B[1] + C[0] + D[0] = 2 + (-1) + (-1) + 0 = 0
35+
<pre>
36+
<strong>Input:</strong> nums1 = [0], nums2 = [0], nums3 = [0], nums4 = [0]
37+
<strong>Output:</strong> 1
3438
</pre>
3539

3640
<p>&nbsp;</p>
41+
<p><strong>Constraints:</strong></p>
42+
43+
<ul>
44+
<li><code>n == nums1.length</code></li>
45+
<li><code>n == nums2.length</code></li>
46+
<li><code>n == nums3.length</code></li>
47+
<li><code>n == nums4.length</code></li>
48+
<li><code>1 &lt;= n &lt;= 200</code></li>
49+
<li><code>-2<sup>28</sup> &lt;= nums1[i], nums2[i], nums3[i], nums4[i] &lt;= 2<sup>28</sup></code></li>
50+
</ul>
3751

3852
### Related Topics
3953
[[Hash Table](../../tag/hash-table/README.md)]

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /