Skip to content

A: new #840

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 10, 2021
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
67 changes: 54 additions & 13 deletions README.md

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions problems/01-matrix/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,7 @@
</ul>

### Related Topics
[[Depth-first Search](../../tag/depth-first-search/README.md)]
[[Breadth-first Search](../../tag/breadth-first-search/README.md)]
[[Breadth-First Search](../../tag/breadth-first-search/README.md)]
[[Array](../../tag/array/README.md)]
[[Dynamic Programming](../../tag/dynamic-programming/README.md)]
[[Matrix](../../tag/matrix/README.md)]
4 changes: 4 additions & 0 deletions problems/132-pattern/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,7 @@

### Related Topics
[[Stack](../../tag/stack/README.md)]
[[Array](../../tag/array/README.md)]
[[Binary Search](../../tag/binary-search/README.md)]
[[Ordered Set](../../tag/ordered-set/README.md)]
[[Monotonic Stack](../../tag/monotonic-stack/README.md)]
1 change: 1 addition & 0 deletions problems/2-keys-keyboard/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ In step 3, we use Paste operation to get &#39;AAA&#39;.
</ul>

### Related Topics
[[Math](../../tag/math/README.md)]
[[Dynamic Programming](../../tag/dynamic-programming/README.md)]

### Similar Questions
Expand Down
4 changes: 3 additions & 1 deletion problems/24-game/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,6 @@
</ul>

### Related Topics
[[Depth-first Search](../../tag/depth-first-search/README.md)]
[[Array](../../tag/array/README.md)]
[[Math](../../tag/math/README.md)]
[[Backtracking](../../tag/backtracking/README.md)]
1 change: 1 addition & 0 deletions problems/3sum-closest/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
### Related Topics
[[Array](../../tag/array/README.md)]
[[Two Pointers](../../tag/two-pointers/README.md)]
[[Sorting](../../tag/sorting/README.md)]

### Similar Questions
1. [3Sum](../3sum) (Medium)
Expand Down
14 changes: 2 additions & 12 deletions problems/3sum-smaller/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,13 @@

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

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

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

<pre>
<strong>Input:</strong> <i>nums</i> = <code>[-2,0,1,3]</code>, and <i>target</i> = 2
<strong>Output:</strong> 2
<strong>Explanation:</strong>&nbsp;Because there are two triplets which sums are less than 2:
&nbsp; [-2,0,1]
[-2,0,3]
</pre>

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

### Related Topics
[[Array](../../tag/array/README.md)]
[[Two Pointers](../../tag/two-pointers/README.md)]
[[Binary Search](../../tag/binary-search/README.md)]
[[Sorting](../../tag/sorting/README.md)]

### Similar Questions
1. [3Sum](../3sum) (Medium)
Expand Down
4 changes: 4 additions & 0 deletions problems/3sum-with-multiplicity/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,8 @@ and two 2s from [2,2,2,2] in 6 ways.
</ul>

### Related Topics
[[Array](../../tag/array/README.md)]
[[Hash Table](../../tag/hash-table/README.md)]
[[Two Pointers](../../tag/two-pointers/README.md)]
[[Counting](../../tag/counting/README.md)]
[[Sorting](../../tag/sorting/README.md)]
1 change: 1 addition & 0 deletions problems/3sum/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
### Related Topics
[[Array](../../tag/array/README.md)]
[[Two Pointers](../../tag/two-pointers/README.md)]
[[Sorting](../../tag/sorting/README.md)]

### Similar Questions
1. [Two Sum](../two-sum) (Easy)
Expand Down
35 changes: 0 additions & 35 deletions problems/4-keys-keyboard/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,44 +11,9 @@

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

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



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


<p><b>Example 1:</b><br />
<pre><b>Input:</b> N = 3
<b>Output:</b> 3
<b>Explanation:</b>
We can at most get 3 A's on screen by pressing following key sequence:
A, A, A
</pre>
</p>

<p><b>Example 2:</b><br />
<pre><b>Input:</b> N = 7
<b>Output:</b> 9
<b>Explanation:</b>
We can at most get 9 A's on screen by pressing following key sequence:
A, A, A, Ctrl A, Ctrl C, Ctrl V, Ctrl V
</pre>
</p>

<p><b>Note:</b><br>
<ol>
<li>1 <= N <= 50 </li>
<li>Answers will be in the range of 32-bit signed integer.</li>
</ol>
</p>

### Related Topics
[[Greedy](../../tag/greedy/README.md)]
[[Math](../../tag/math/README.md)]
[[Dynamic Programming](../../tag/dynamic-programming/README.md)]

Expand Down
2 changes: 1 addition & 1 deletion problems/4sum-ii/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ The two tuples are:
</ul>

### Related Topics
[[Array](../../tag/array/README.md)]
[[Hash Table](../../tag/hash-table/README.md)]
[[Binary Search](../../tag/binary-search/README.md)]

### Similar Questions
1. [4Sum](../4sum) (Medium)
2 changes: 1 addition & 1 deletion problems/4sum/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@

### Related Topics
[[Array](../../tag/array/README.md)]
[[Hash Table](../../tag/hash-table/README.md)]
[[Two Pointers](../../tag/two-pointers/README.md)]
[[Sorting](../../tag/sorting/README.md)]

### Similar Questions
1. [Two Sum](../two-sum) (Easy)
Expand Down
5 changes: 4 additions & 1 deletion problems/accounts-merge/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,11 @@ We could return these lists in any order, for example the answer [[&#39;Mary&#39
</ul>

### Related Topics
[[Depth-first Search](../../tag/depth-first-search/README.md)]
[[Depth-First Search](../../tag/depth-first-search/README.md)]
[[Breadth-First Search](../../tag/breadth-first-search/README.md)]
[[Union Find](../../tag/union-find/README.md)]
[[Array](../../tag/array/README.md)]
[[String](../../tag/string/README.md)]

### Similar Questions
1. [Redundant Connection](../redundant-connection) (Medium)
Expand Down
43 changes: 2 additions & 41 deletions problems/active-businesses/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,46 +11,7 @@

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

<p>Table: <code>Events</code></p>

<pre>
+---------------+---------+
| Column Name | Type |
+---------------+---------+
| business_id | int |
| event_type | varchar |
| occurences | int |
+---------------+---------+
(business_id, event_type) is the primary key of this table.
Each row in the table logs the info that an event of some type occured at some business for a number of times.</pre>

<p>&nbsp;</p>

<p>Write an SQL query to find all <em>active businesses</em>.</p>

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

<p>The query result format is in the following example:</p>

<pre>
Events table:
+-------------+------------+------------+
| business_id | event_type | occurences |
+-------------+------------+------------+
| 1 | reviews | 7 |
| 3 | reviews | 3 |
| 1 | ads | 11 |
| 2 | ads | 7 |
| 3 | ads | 6 |
| 1 | page views | 3 |
| 2 | page views | 12 |
+-------------+------------+------------+

Result table:
+-------------+
| business_id |
+-------------+
| 1 |
+-------------+
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.
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>
### Related Topics
[[Database](../../tag/database/README.md)]
3 changes: 3 additions & 0 deletions problems/active-users/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@
## [1454. Active Users (Medium)](https://leetcode.com/problems/active-users "活跃用户")



### Related Topics
[[Database](../../tag/database/README.md)]
65 changes: 2 additions & 63 deletions problems/activity-participants/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,68 +11,7 @@

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

<p>Table: <code>Friends</code></p>
<pre>
+---------------+---------+
| Column Name | Type |
+---------------+---------+
| id | int |
| name | varchar |
| activity | varchar |
+---------------+---------+
id is the id of the friend and primary key for this table.
name is the name of the friend.
activity is the name of the activity which the friend takes part in.
</pre>

<p>Table: <code>Activities</code></p>
<pre>
+---------------+---------+
| Column Name | Type |
+---------------+---------+
| id | int |
| name | varchar |
+---------------+---------+
id is the primary key for this table.
name is the name of the activity.
</pre>

Write an SQL query to find the names of all the activities with neither maximum, nor minimum number of participants.

Return the result table in any order. Each activity in table Activities is performed by any person in the table Friends.

The query result format is in the following example:

Friends table:
<pre>
+------+--------------+---------------+
| id | name | activity |
+------+--------------+---------------+
| 1 | Jonathan D. | Eating |
| 2 | Jade W. | Singing |
| 3 | Victor J. | Singing |
| 4 | Elvis Q. | Eating |
| 5 | Daniel A. | Eating |
| 6 | Bob B. | Horse Riding |
+------+--------------+---------------+

Activities table:
+------+--------------+
| id | name |
+------+--------------+
| 1 | Eating |
| 2 | Singing |
| 3 | Horse Riding |
+------+--------------+

Result table:
+--------------+
| results |
+--------------+
| Singing |
+--------------+

Eating activity is performed by 3 friends, maximum number of participants, (Jonathan D. , Elvis Q. and Daniel A.)
Horse Riding activity is performed by 1 friend, minimum number of participants, (Bob B.)
Singing is performed by 2 friends (Victor J. and Jade W.)
</pre>
### Related Topics
[[Database](../../tag/database/README.md)]
Original file line number Diff line number Diff line change
Expand Up @@ -11,44 +11,7 @@

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

<p>Table: <code>ActorDirector</code></p>

<pre>
+-------------+---------+
| Column Name | Type |
+-------------+---------+
| actor_id | int |
| director_id | int |
| timestamp | int |
+-------------+---------+
timestamp is the primary key column for this table.
</pre>

<p>&nbsp;</p>

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

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

<pre>
ActorDirector table:
+-------------+-------------+-------------+
| actor_id | director_id | timestamp |
+-------------+-------------+-------------+
| 1 | 1 | 0 |
| 1 | 1 | 1 |
| 1 | 1 | 2 |
| 1 | 2 | 3 |
| 1 | 2 | 4 |
| 2 | 1 | 5 |
| 2 | 1 | 6 |
+-------------+-------------+-------------+

Result table:
+-------------+-------------+
| actor_id | director_id |
+-------------+-------------+
| 1 | 1 |
+-------------+-------------+
The only pair is (1, 1) where they cooperated exactly 3 times.
</pre>
### Related Topics
[[Database](../../tag/database/README.md)]
3 changes: 3 additions & 0 deletions problems/ad-free-sessions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@
## [1809. Ad-Free Sessions (Easy)](https://leetcode.com/problems/ad-free-sessions "没有广告的剧集")



### Related Topics
[[Database](../../tag/database/README.md)]
2 changes: 2 additions & 0 deletions problems/add-binary/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@
</ul>

### Related Topics
[[Bit Manipulation](../../tag/bit-manipulation/README.md)]
[[Math](../../tag/math/README.md)]
[[String](../../tag/string/README.md)]
[[Simulation](../../tag/simulation/README.md)]

### Similar Questions
1. [Add Two Numbers](../add-two-numbers) (Medium)
Expand Down
31 changes: 4 additions & 27 deletions problems/add-bold-tag-in-string/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,37 +11,14 @@

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

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.

<p><b>Example 1:</b><br />
<pre>
<b>Input:</b>
s = "abcxyz123"
dict = ["abc","123"]
<b>Output:</b>
"&lt;b&gt;abc&lt;/b&gt;xyz&lt;b&gt;123&lt;/b&gt;"
</pre>
</p>

<p><b>Example 2:</b><br />
<pre>
<b>Input:</b>
s = "aaabbcc"
dict = ["aaa","aab","bc"]
<b>Output:</b>
"&lt;b&gt;aaabbc&lt;/b&gt;c"
</pre>
</p>

<p><b>Note:</b><br>
<ol>
<li>The given dict won't contain duplicates, and its length won't exceed 100.</li>
<li>All the strings in input have length in range [1, 1000]. </li>
</ol>
</p>

### Related Topics
[[Trie](../../tag/trie/README.md)]
[[Array](../../tag/array/README.md)]
[[Hash Table](../../tag/hash-table/README.md)]
[[String](../../tag/string/README.md)]
[[String Matching](../../tag/string-matching/README.md)]

### Similar Questions
1. [Merge Intervals](../merge-intervals) (Medium)
Expand Down
Loading