Skip to content

Commit 62f1dec

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

File tree

1,787 files changed

+11988
-15819
lines changed

Some content is hidden

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

1,787 files changed

+11988
-15819
lines changed

README.md

+54-13
Large diffs are not rendered by default.

problems/01-matrix/README.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,7 @@
4343
</ul>
4444

4545
### Related Topics
46-
[[Depth-first Search](../../tag/depth-first-search/README.md)]
47-
[[Breadth-first Search](../../tag/breadth-first-search/README.md)]
46+
[[Breadth-First Search](../../tag/breadth-first-search/README.md)]
47+
[[Array](../../tag/array/README.md)]
48+
[[Dynamic Programming](../../tag/dynamic-programming/README.md)]
49+
[[Matrix](../../tag/matrix/README.md)]

problems/132-pattern/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,7 @@
5151

5252
### Related Topics
5353
[[Stack](../../tag/stack/README.md)]
54+
[[Array](../../tag/array/README.md)]
55+
[[Binary Search](../../tag/binary-search/README.md)]
56+
[[Ordered Set](../../tag/ordered-set/README.md)]
57+
[[Monotonic Stack](../../tag/monotonic-stack/README.md)]

problems/2-keys-keyboard/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ In step 3, we use Paste operation to get &#39;AAA&#39;.
4747
</ul>
4848

4949
### Related Topics
50+
[[Math](../../tag/math/README.md)]
5051
[[Dynamic Programming](../../tag/dynamic-programming/README.md)]
5152

5253
### Similar Questions

problems/24-game/README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,6 @@
6060
</ul>
6161

6262
### Related Topics
63-
[[Depth-first Search](../../tag/depth-first-search/README.md)]
63+
[[Array](../../tag/array/README.md)]
64+
[[Math](../../tag/math/README.md)]
65+
[[Backtracking](../../tag/backtracking/README.md)]

problems/3sum-closest/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
### Related Topics
3535
[[Array](../../tag/array/README.md)]
3636
[[Two Pointers](../../tag/two-pointers/README.md)]
37+
[[Sorting](../../tag/sorting/README.md)]
3738

3839
### Similar Questions
3940
1. [3Sum](../3sum) (Medium)

problems/3sum-smaller/README.md

+2-12
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,13 @@
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>
1514

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

2816
### Related Topics
2917
[[Array](../../tag/array/README.md)]
3018
[[Two Pointers](../../tag/two-pointers/README.md)]
19+
[[Binary Search](../../tag/binary-search/README.md)]
20+
[[Sorting](../../tag/sorting/README.md)]
3121

3222
### Similar Questions
3323
1. [3Sum](../3sum) (Medium)

problems/3sum-with-multiplicity/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,8 @@ and two 2s from [2,2,2,2] in 6 ways.
5050
</ul>
5151

5252
### Related Topics
53+
[[Array](../../tag/array/README.md)]
54+
[[Hash Table](../../tag/hash-table/README.md)]
5355
[[Two Pointers](../../tag/two-pointers/README.md)]
56+
[[Counting](../../tag/counting/README.md)]
57+
[[Sorting](../../tag/sorting/README.md)]

problems/3sum/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
### Related Topics
3838
[[Array](../../tag/array/README.md)]
3939
[[Two Pointers](../../tag/two-pointers/README.md)]
40+
[[Sorting](../../tag/sorting/README.md)]
4041

4142
### Similar Questions
4243
1. [Two Sum](../two-sum) (Easy)

problems/4-keys-keyboard/README.md

-35
Original file line numberDiff line numberDiff line change
@@ -11,44 +11,9 @@
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>
1914

2015

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-
5016
### Related Topics
51-
[[Greedy](../../tag/greedy/README.md)]
5217
[[Math](../../tag/math/README.md)]
5318
[[Dynamic Programming](../../tag/dynamic-programming/README.md)]
5419

problems/4sum-ii/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ The two tuples are:
5050
</ul>
5151

5252
### Related Topics
53+
[[Array](../../tag/array/README.md)]
5354
[[Hash Table](../../tag/hash-table/README.md)]
54-
[[Binary Search](../../tag/binary-search/README.md)]
5555

5656
### Similar Questions
5757
1. [4Sum](../4sum) (Medium)

problems/4sum/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@
4747

4848
### Related Topics
4949
[[Array](../../tag/array/README.md)]
50-
[[Hash Table](../../tag/hash-table/README.md)]
5150
[[Two Pointers](../../tag/two-pointers/README.md)]
51+
[[Sorting](../../tag/sorting/README.md)]
5252

5353
### Similar Questions
5454
1. [Two Sum](../two-sum) (Easy)

problems/accounts-merge/README.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,11 @@ We could return these lists in any order, for example the answer [[&#39;Mary&#39
4949
</ul>
5050

5151
### Related Topics
52-
[[Depth-first Search](../../tag/depth-first-search/README.md)]
52+
[[Depth-First Search](../../tag/depth-first-search/README.md)]
53+
[[Breadth-First Search](../../tag/breadth-first-search/README.md)]
5354
[[Union Find](../../tag/union-find/README.md)]
55+
[[Array](../../tag/array/README.md)]
56+
[[String](../../tag/string/README.md)]
5457

5558
### Similar Questions
5659
1. [Redundant Connection](../redundant-connection) (Medium)

problems/active-businesses/README.md

+2-41
Original file line numberDiff line numberDiff line change
@@ -11,46 +11,7 @@
1111

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

14-
<p>Table: <code>Events</code></p>
1514

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

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>
16+
### Related Topics
17+
[[Database](../../tag/database/README.md)]

problems/active-users/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@
1212
## [1454. Active Users (Medium)](https://leetcode.com/problems/active-users "活跃用户")
1313

1414

15+
16+
### Related Topics
17+
[[Database](../../tag/database/README.md)]

problems/activity-participants/README.md

+2-63
Original file line numberDiff line numberDiff line change
@@ -11,68 +11,7 @@
1111

1212
## [1355. Activity Participants (Medium)](https://leetcode.com/problems/activity-participants "活动参与者")
1313

14-
<p>Table: <code>Friends</code></p>
15-
<pre>
16-
+---------------+---------+
17-
| Column Name | Type |
18-
+---------------+---------+
19-
| id | int |
20-
| name | varchar |
21-
| activity | varchar |
22-
+---------------+---------+
23-
id is the id of the friend and primary key for this table.
24-
name is the name of the friend.
25-
activity is the name of the activity which the friend takes part in.
26-
</pre>
2714

28-
<p>Table: <code>Activities</code></p>
29-
<pre>
30-
+---------------+---------+
31-
| Column Name | Type |
32-
+---------------+---------+
33-
| id | int |
34-
| name | varchar |
35-
+---------------+---------+
36-
id is the primary key for this table.
37-
name is the name of the activity.
38-
</pre>
39-
40-
Write an SQL query to find the names of all the activities with neither maximum, nor minimum number of participants.
4115

42-
Return the result table in any order. Each activity in table Activities is performed by any person in the table Friends.
43-
44-
The query result format is in the following example:
45-
46-
Friends table:
47-
<pre>
48-
+------+--------------+---------------+
49-
| id | name | activity |
50-
+------+--------------+---------------+
51-
| 1 | Jonathan D. | Eating |
52-
| 2 | Jade W. | Singing |
53-
| 3 | Victor J. | Singing |
54-
| 4 | Elvis Q. | Eating |
55-
| 5 | Daniel A. | Eating |
56-
| 6 | Bob B. | Horse Riding |
57-
+------+--------------+---------------+
58-
59-
Activities table:
60-
+------+--------------+
61-
| id | name |
62-
+------+--------------+
63-
| 1 | Eating |
64-
| 2 | Singing |
65-
| 3 | Horse Riding |
66-
+------+--------------+
67-
68-
Result table:
69-
+--------------+
70-
| results |
71-
+--------------+
72-
| Singing |
73-
+--------------+
74-
75-
Eating activity is performed by 3 friends, maximum number of participants, (Jonathan D. , Elvis Q. and Daniel A.)
76-
Horse Riding activity is performed by 1 friend, minimum number of participants, (Bob B.)
77-
Singing is performed by 2 friends (Victor J. and Jade W.)
78-
</pre>
16+
### Related Topics
17+
[[Database](../../tag/database/README.md)]

problems/actors-and-directors-who-cooperated-at-least-three-times/README.md

+2-39
Original file line numberDiff line numberDiff line change
@@ -11,44 +11,7 @@
1111

1212
## [1050. Actors and Directors Who Cooperated At Least Three Times (Easy)](https://leetcode.com/problems/actors-and-directors-who-cooperated-at-least-three-times "合作过至少三次的演员和导演")
1313

14-
<p>Table: <code>ActorDirector</code></p>
1514

16-
<pre>
17-
+-------------+---------+
18-
| Column Name | Type |
19-
+-------------+---------+
20-
| actor_id | int |
21-
| director_id | int |
22-
| timestamp | int |
23-
+-------------+---------+
24-
timestamp is the primary key column for this table.
25-
</pre>
2615

27-
<p>&nbsp;</p>
28-
29-
<p>Write a SQL query for a report that provides the pairs <code>(actor_id, director_id)</code> where the actor have cooperated with the director at least 3 times.</p>
30-
31-
<p><strong>Example:</strong></p>
32-
33-
<pre>
34-
ActorDirector table:
35-
+-------------+-------------+-------------+
36-
| actor_id | director_id | timestamp |
37-
+-------------+-------------+-------------+
38-
| 1 | 1 | 0 |
39-
| 1 | 1 | 1 |
40-
| 1 | 1 | 2 |
41-
| 1 | 2 | 3 |
42-
| 1 | 2 | 4 |
43-
| 2 | 1 | 5 |
44-
| 2 | 1 | 6 |
45-
+-------------+-------------+-------------+
46-
47-
Result table:
48-
+-------------+-------------+
49-
| actor_id | director_id |
50-
+-------------+-------------+
51-
| 1 | 1 |
52-
+-------------+-------------+
53-
The only pair is (1, 1) where they cooperated exactly 3 times.
54-
</pre>
16+
### Related Topics
17+
[[Database](../../tag/database/README.md)]

problems/ad-free-sessions/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@
1212
## [1809. Ad-Free Sessions (Easy)](https://leetcode.com/problems/ad-free-sessions "没有广告的剧集")
1313

1414

15+
16+
### Related Topics
17+
[[Database](../../tag/database/README.md)]

problems/add-binary/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,10 @@
3131
</ul>
3232

3333
### Related Topics
34+
[[Bit Manipulation](../../tag/bit-manipulation/README.md)]
3435
[[Math](../../tag/math/README.md)]
3536
[[String](../../tag/string/README.md)]
37+
[[Simulation](../../tag/simulation/README.md)]
3638

3739
### Similar Questions
3840
1. [Add Two Numbers](../add-two-numbers) (Medium)

problems/add-bold-tag-in-string/README.md

+4-27
Original file line numberDiff line numberDiff line change
@@ -11,37 +11,14 @@
1111

1212
## [616. Add Bold Tag in String (Medium)](https://leetcode.com/problems/add-bold-tag-in-string "给字符串添加加粗标签")
1313

14-
Given a string <b>s</b> and a list of strings <b>dict</b>, you need to add a closed pair of bold tag <code>&lt;b&gt;</code> and <code>&lt;/b&gt;</code> to wrap the substrings in s that exist in dict. If two such substrings overlap, you need to wrap them together by only one pair of closed bold tag. Also, if two substrings wrapped by bold tags are consecutive, you need to combine them.
1514

16-
<p><b>Example 1:</b><br />
17-
<pre>
18-
<b>Input:</b>
19-
s = "abcxyz123"
20-
dict = ["abc","123"]
21-
<b>Output:</b>
22-
"&lt;b&gt;abc&lt;/b&gt;xyz&lt;b&gt;123&lt;/b&gt;"
23-
</pre>
24-
</p>
25-
26-
<p><b>Example 2:</b><br />
27-
<pre>
28-
<b>Input:</b>
29-
s = "aaabbcc"
30-
dict = ["aaa","aab","bc"]
31-
<b>Output:</b>
32-
"&lt;b&gt;aaabbc&lt;/b&gt;c"
33-
</pre>
34-
</p>
35-
36-
<p><b>Note:</b><br>
37-
<ol>
38-
<li>The given dict won't contain duplicates, and its length won't exceed 100.</li>
39-
<li>All the strings in input have length in range [1, 1000]. </li>
40-
</ol>
41-
</p>
4215

4316
### Related Topics
17+
[[Trie](../../tag/trie/README.md)]
18+
[[Array](../../tag/array/README.md)]
19+
[[Hash Table](../../tag/hash-table/README.md)]
4420
[[String](../../tag/string/README.md)]
21+
[[String Matching](../../tag/string-matching/README.md)]
4522

4623
### Similar Questions
4724
1. [Merge Intervals](../merge-intervals) (Medium)

0 commit comments

Comments
 (0)