-
Notifications
You must be signed in to change notification settings - Fork 130
A: new #776
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
A: new #776
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
problems/circle-and-rectangle-overlapping/README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<!--|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](../construct-k-palindrome-strings "Construct K Palindrome Strings") | ||
|
||
[Next >](../reducing-dishes "Reducing Dishes") | ||
|
||
## [1401. Circle and Rectangle Overlapping (Medium)](https://leetcode.com/problems/circle-and-rectangle-overlapping "圆和矩形是否有重叠") | ||
|
||
<p>Given a circle represented as (<code>radius</code>, <code>x_center</code>, <code>y_center</code>) and an axis-aligned rectangle represented as (<code>x1</code>, <code>y1</code>, <code>x2</code>, <code>y2</code>), where (<code>x1</code>, <code>y1</code>) are the coordinates of the bottom-left corner, and (<code>x2</code>, <code>y2</code>) are the coordinates of the top-right corner of the rectangle.</p> | ||
|
||
<p>Return True if the circle and rectangle are overlapped otherwise return False.</p> | ||
|
||
<p>In other words, check if there are <strong>any </strong>point (xi, yi) such that belongs to the circle and the rectangle at the same time.</p> | ||
|
||
<p> </p> | ||
<p><strong>Example 1:</strong></p> | ||
|
||
<p><img alt="" src="https://assets.leetcode.com/uploads/2020/02/20/sample_4_1728.png" style="width: 258px; height: 167px;" /></p> | ||
|
||
<pre> | ||
<strong>Input:</strong> radius = 1, x_center = 0, y_center = 0, x1 = 1, y1 = -1, x2 = 3, y2 = 1 | ||
<strong>Output:</strong> true | ||
<strong>Explanation:</strong> Circle and rectangle share the point (1,0) | ||
</pre> | ||
|
||
<p><strong>Example 2:</strong></p> | ||
|
||
<p><strong><img alt="" src="https://assets.leetcode.com/uploads/2020/02/20/sample_2_1728.png" style="width: 150px; height: 135px;" /></strong></p> | ||
|
||
<pre> | ||
<strong>Input:</strong> radius = 1, x_center = 0, y_center = 0, x1 = -1, y1 = 0, x2 = 0, y2 = 1 | ||
<strong>Output:</strong> true | ||
</pre> | ||
|
||
<p><strong>Example 3:</strong></p> | ||
|
||
<p><strong><img alt="" src="https://assets.leetcode.com/uploads/2020/03/03/sample_6_1728.png" style="width: 175px; height: 165px;" /></strong></p> | ||
|
||
<pre> | ||
<strong>Input:</strong> radius = 1, x_center = 1, y_center = 1, x1 = -3, y1 = -3, x2 = 3, y2 = 3 | ||
<strong>Output:</strong> true | ||
</pre> | ||
|
||
<p><strong>Example 4:</strong></p> | ||
|
||
<pre> | ||
<strong>Input:</strong> radius = 1, x_center = 1, y_center = 1, x1 = 1, y1 = -3, x2 = 2, y2 = -1 | ||
<strong>Output:</strong> false | ||
</pre> | ||
|
||
<p> </p> | ||
<p><strong>Constraints:</strong></p> | ||
|
||
<ul> | ||
<li><code>1 <= radius <= 2000</code></li> | ||
<li><code>-10^4 <= x_center, y_center, x1, y1, x2, y2 <= 10^4</code></li> | ||
<li><code>x1 < x2</code></li> | ||
<li><code>y1 < y2</code></li> | ||
</ul> | ||
|
||
### Related Topics | ||
[[Geometry](../../tag/geometry/README.md)] | ||
|
||
### Hints | ||
<details> | ||
<summary>Hint 1</summary> | ||
Locate the closest point of the square to the circle, you can then find the distance from this point to the center of the circle and check if this is less than or equal to the radius. | ||
</details> |
86 changes: 86 additions & 0 deletions
problems/construct-k-palindrome-strings/README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<!--|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](../count-largest-group "Count Largest Group") | ||
|
||
[Next >](../circle-and-rectangle-overlapping "Circle and Rectangle Overlapping") | ||
|
||
## [1400. Construct K Palindrome Strings (Medium)](https://leetcode.com/problems/construct-k-palindrome-strings "构造 K 个回文字符串") | ||
|
||
<p>Given a string <code>s</code> and an integer <code>k</code>. You should construct <code>k</code> non-empty <strong>palindrome</strong> strings using <strong>all the characters</strong> in <code>s</code>.</p> | ||
|
||
<p>Return <em><strong>True</strong></em> if you can use all the characters in <code>s</code> to construct <code>k</code> palindrome strings or <em><strong>False</strong></em> otherwise.</p> | ||
|
||
<p> </p> | ||
<p><strong>Example 1:</strong></p> | ||
|
||
<pre> | ||
<strong>Input:</strong> s = "annabelle", k = 2 | ||
<strong>Output:</strong> true | ||
<strong>Explanation:</strong> You can construct two palindromes using all characters in s. | ||
Some possible constructions "anna" + "elble", "anbna" + "elle", "anellena" + "b" | ||
</pre> | ||
|
||
<p><strong>Example 2:</strong></p> | ||
|
||
<pre> | ||
<strong>Input:</strong> s = "leetcode", k = 3 | ||
<strong>Output:</strong> false | ||
<strong>Explanation:</strong> It is impossible to construct 3 palindromes using all the characters of s. | ||
</pre> | ||
|
||
<p><strong>Example 3:</strong></p> | ||
|
||
<pre> | ||
<strong>Input:</strong> s = "true", k = 4 | ||
<strong>Output:</strong> true | ||
<strong>Explanation:</strong> The only possible solution is to put each character in a separate string. | ||
</pre> | ||
|
||
<p><strong>Example 4:</strong></p> | ||
|
||
<pre> | ||
<strong>Input:</strong> s = "yzyzyzyzyzyzyzy", k = 2 | ||
<strong>Output:</strong> true | ||
<strong>Explanation:</strong> Simply you can put all z's in one string and all y's in the other string. Both strings will be palindrome. | ||
</pre> | ||
|
||
<p><strong>Example 5:</strong></p> | ||
|
||
<pre> | ||
<strong>Input:</strong> s = "cr", k = 7 | ||
<strong>Output:</strong> false | ||
<strong>Explanation:</strong> We don't have enough characters in s to construct 7 palindromes. | ||
</pre> | ||
|
||
<p> </p> | ||
<p><strong>Constraints:</strong></p> | ||
|
||
<ul> | ||
<li><code>1 <= s.length <= 10^5</code></li> | ||
<li>All characters in <code>s</code> are lower-case English letters.</li> | ||
<li><code>1 <= k <= 10^5</code></li> | ||
</ul> | ||
|
||
### Related Topics | ||
[[Greedy](../../tag/greedy/README.md)] | ||
|
||
### Hints | ||
<details> | ||
<summary>Hint 1</summary> | ||
If the s.length < k we cannot construct k strings from s and answer is false. | ||
</details> | ||
|
||
<details> | ||
<summary>Hint 2</summary> | ||
If the number of characters that have odd counts is > k then the minimum number of palindrome strings we can construct is > k and answer is false. | ||
</details> | ||
|
||
<details> | ||
<summary>Hint 3</summary> | ||
Otherwise you can construct exactly k palindrome strings and answer is true (why ?). | ||
</details> |
64 changes: 64 additions & 0 deletions
problems/count-largest-group/README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<!--|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](../customers-who-bought-products-a-and-b-but-not-c "Customers Who Bought Products A and B but Not C") | ||
|
||
[Next >](../construct-k-palindrome-strings "Construct K Palindrome Strings") | ||
|
||
## [1399. Count Largest Group (Easy)](https://leetcode.com/problems/count-largest-group "统计最大组的数目") | ||
|
||
<p>Given an integer <code>n</code>. Each number from <code>1</code> to <code>n</code> is grouped according to the sum of its digits. </p> | ||
|
||
<p>Return how many groups have the largest size.</p> | ||
|
||
<p> </p> | ||
<p><strong>Example 1:</strong></p> | ||
|
||
<pre> | ||
<strong>Input:</strong> n = 13 | ||
<strong>Output:</strong> 4 | ||
<strong>Explanation:</strong> There are 9 groups in total, they are grouped according sum of its digits of numbers from 1 to 13: | ||
[1,10], [2,11], [3,12], [4,13], [5], [6], [7], [8], [9]. There are 4 groups with largest size. | ||
</pre> | ||
|
||
<p><strong>Example 2:</strong></p> | ||
|
||
<pre> | ||
<strong>Input:</strong> n = 2 | ||
<strong>Output:</strong> 2 | ||
<strong>Explanation:</strong> There are 2 groups [1], [2] of size 1. | ||
</pre> | ||
|
||
<p><strong>Example 3:</strong></p> | ||
|
||
<pre> | ||
<strong>Input:</strong> n = 15 | ||
<strong>Output:</strong> 6 | ||
</pre> | ||
|
||
<p><strong>Example 4:</strong></p> | ||
|
||
<pre> | ||
<strong>Input:</strong> n = 24 | ||
<strong>Output:</strong> 5 | ||
</pre> | ||
|
||
<p> </p> | ||
<p><strong>Constraints:</strong></p> | ||
|
||
<ul> | ||
<li><code>1 <= n <= 10^4</code></li> | ||
</ul> | ||
|
||
### Related Topics | ||
[[Array](../../tag/array/README.md)] | ||
|
||
### Hints | ||
<details> | ||
<summary>Hint 1</summary> | ||
Count the digit sum for each integer in the range and find out the largest groups. | ||
</details> |
14 changes: 14 additions & 0 deletions
problems/customers-who-bought-products-a-and-b-but-not-c/README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<!--|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](../find-all-good-strings "Find All Good Strings") | ||
|
||
[Next >](../count-largest-group "Count Largest Group") | ||
|
||
## [1398. Customers Who Bought Products A and B but Not C (Medium)](https://leetcode.com/problems/customers-who-bought-products-a-and-b-but-not-c "") | ||
|
||
|
17 changes: 17 additions & 0 deletions
problems/customers-who-bought-products-a-and-b-but-not-c/mysql_schemas.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
Create table If Not Exists Customers (customer_id int, customer_name varchar(30)); | ||
Create table If Not Exists Orders (order_id int, customer_id int, product_name varchar(30)); | ||
Truncate table Customers; | ||
insert into Customers (customer_id, customer_name) values ('1', 'Daniel'); | ||
insert into Customers (customer_id, customer_name) values ('2', 'Diana'); | ||
insert into Customers (customer_id, customer_name) values ('3', 'Elizabeth'); | ||
insert into Customers (customer_id, customer_name) values ('4', 'Jhon'); | ||
Truncate table Orders; | ||
insert into Orders (order_id, customer_id, product_name) values ('10', '1', 'A'); | ||
insert into Orders (order_id, customer_id, product_name) values ('20', '1', 'B'); | ||
insert into Orders (order_id, customer_id, product_name) values ('30', '1', 'D'); | ||
insert into Orders (order_id, customer_id, product_name) values ('40', '1', 'C'); | ||
insert into Orders (order_id, customer_id, product_name) values ('50', '2', 'A'); | ||
insert into Orders (order_id, customer_id, product_name) values ('60', '3', 'A'); | ||
insert into Orders (order_id, customer_id, product_name) values ('70', '3', 'B'); | ||
insert into Orders (order_id, customer_id, product_name) values ('80', '3', 'D'); | ||
insert into Orders (order_id, customer_id, product_name) values ('90', '4', 'C'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.