You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+10-1Lines changed: 10 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -62,11 +62,20 @@ LeetCode Problems' Solutions
62
62
63
63
| # | Title | Solution | Difficulty |
64
64
| :-: | - | - | :-: |
65
+
| <spanid="1406">1406</span> |[Stone Game III](https://leetcode.com/problems/stone-game-iii"石子游戏 III")|[Go](problems/stone-game-iii)| Hard |
66
+
| <spanid="1405">1405</span> |[Longest Happy String](https://leetcode.com/problems/longest-happy-string"最长快乐字符串")|[Go](problems/longest-happy-string)| Medium |
67
+
| <spanid="1404">1404</span> |[Number of Steps to Reduce a Number in Binary Representation to One](https://leetcode.com/problems/number-of-steps-to-reduce-a-number-in-binary-representation-to-one"将二进制表示减到 1 的步骤数")|[Go](problems/number-of-steps-to-reduce-a-number-in-binary-representation-to-one)| Medium |
68
+
| <spanid="1403">1403</span> |[Minimum Subsequence in Non-Increasing Order](https://leetcode.com/problems/minimum-subsequence-in-non-increasing-order"非递增顺序的最小子序列")|[Go](problems/minimum-subsequence-in-non-increasing-order)| Easy |
69
+
| <spanid="1402">1402</span> |[Reducing Dishes](https://leetcode.com/problems/reducing-dishes"做菜顺序")|[Go](problems/reducing-dishes)| Hard |
70
+
| <spanid="1401">1401</span> |[Circle and Rectangle Overlapping](https://leetcode.com/problems/circle-and-rectangle-overlapping"圆和矩形是否有重叠")|[Go](problems/circle-and-rectangle-overlapping)| Medium |
71
+
| <spanid="1400">1400</span> |[Construct K Palindrome Strings](https://leetcode.com/problems/construct-k-palindrome-strings"构造 K 个回文字符串")|[Go](problems/construct-k-palindrome-strings)| Medium |
72
+
| <spanid="1399">1399</span> |[Count Largest Group](https://leetcode.com/problems/count-largest-group"统计最大组的数目")|[Go](problems/count-largest-group)| Easy |
73
+
| <spanid="1398">1398</span> |[Customers Who Bought Products A and B but Not C](https://leetcode.com/problems/customers-who-bought-products-a-and-b-but-not-c) 🔒 |[MySQL](problems/customers-who-bought-products-a-and-b-but-not-c)| Medium |
65
74
| <spanid="1397">1397</span> |[Find All Good Strings](https://leetcode.com/problems/find-all-good-strings"找到所有好字符串")|[Go](problems/find-all-good-strings)| Hard |
66
75
| <spanid="1396">1396</span> |[Design Underground System](https://leetcode.com/problems/design-underground-system"设计地铁系统")|[Go](problems/design-underground-system)| Medium |
67
76
| <spanid="1395">1395</span> |[Count Number of Teams](https://leetcode.com/problems/count-number-of-teams"统计作战单位数")|[Go](problems/count-number-of-teams)| Medium |
68
77
| <spanid="1394">1394</span> |[Find Lucky Integer in an Array](https://leetcode.com/problems/find-lucky-integer-in-an-array"找出数组中的幸运数")|[Go](problems/find-lucky-integer-in-an-array)| Easy |
69
-
| <spanid="1393">1393</span> |[Capital Gain/Loss](https://leetcode.com/problems/capital-gainloss) 🔒 |[MySQL](problems/capital-gainloss)| Medium |
78
+
| <spanid="1393">1393</span> |[Capital Gain/Loss](https://leetcode.com/problems/capital-gainloss"股票的资本损益") 🔒 |[MySQL](problems/capital-gainloss)| Medium |
70
79
| <spanid="1392">1392</span> |[Longest Happy Prefix](https://leetcode.com/problems/longest-happy-prefix"最长快乐前缀")|[Go](problems/longest-happy-prefix)| Hard |
71
80
| <spanid="1391">1391</span> |[Check if There is a Valid Path in a Grid](https://leetcode.com/problems/check-if-there-is-a-valid-path-in-a-grid"检查网格中是否存在有效路径")|[Go](problems/check-if-there-is-a-valid-path-in-a-grid)| Medium |
72
81
| <spanid="1390">1390</span> |[Four Divisors](https://leetcode.com/problems/four-divisors"四因数")|[Go](problems/four-divisors)| Medium |
[< Previous](../construct-k-palindrome-strings"Construct K Palindrome Strings")
9
+
10
+
[Next >](../reducing-dishes"Reducing Dishes")
11
+
12
+
## [1401. Circle and Rectangle Overlapping (Medium)](https://leetcode.com/problems/circle-and-rectangle-overlapping"圆和矩形是否有重叠")
13
+
14
+
<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>
15
+
16
+
<p>Return True if the circle and rectangle are overlapped otherwise return False.</p>
17
+
18
+
<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>
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.
[< Previous](../count-largest-group"Count Largest Group")
9
+
10
+
[Next >](../circle-and-rectangle-overlapping"Circle and Rectangle Overlapping")
11
+
12
+
## [1400. Construct K Palindrome Strings (Medium)](https://leetcode.com/problems/construct-k-palindrome-strings"构造 K 个回文字符串")
13
+
14
+
<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>
15
+
16
+
<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>
17
+
18
+
<p> </p>
19
+
<p><strong>Example 1:</strong></p>
20
+
21
+
<pre>
22
+
<strong>Input:</strong> s = "annabelle", k = 2
23
+
<strong>Output:</strong> true
24
+
<strong>Explanation:</strong> You can construct two palindromes using all characters in s.
25
+
Some possible constructions "anna" + "elble", "anbna" + "elle", "anellena" + "b"
26
+
</pre>
27
+
28
+
<p><strong>Example 2:</strong></p>
29
+
30
+
<pre>
31
+
<strong>Input:</strong> s = "leetcode", k = 3
32
+
<strong>Output:</strong> false
33
+
<strong>Explanation:</strong> It is impossible to construct 3 palindromes using all the characters of s.
34
+
</pre>
35
+
36
+
<p><strong>Example 3:</strong></p>
37
+
38
+
<pre>
39
+
<strong>Input:</strong> s = "true", k = 4
40
+
<strong>Output:</strong> true
41
+
<strong>Explanation:</strong> The only possible solution is to put each character in a separate string.
42
+
</pre>
43
+
44
+
<p><strong>Example 4:</strong></p>
45
+
46
+
<pre>
47
+
<strong>Input:</strong> s = "yzyzyzyzyzyzyzy", k = 2
48
+
<strong>Output:</strong> true
49
+
<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.
50
+
</pre>
51
+
52
+
<p><strong>Example 5:</strong></p>
53
+
54
+
<pre>
55
+
<strong>Input:</strong> s = "cr", k = 7
56
+
<strong>Output:</strong> false
57
+
<strong>Explanation:</strong> We don't have enough characters in s to construct 7 palindromes.
58
+
</pre>
59
+
60
+
<p> </p>
61
+
<p><strong>Constraints:</strong></p>
62
+
63
+
<ul>
64
+
<li><code>1 <= s.length <= 10^5</code></li>
65
+
<li>All characters in <code>s</code> are lower-case English letters.</li>
66
+
<li><code>1 <= k <= 10^5</code></li>
67
+
</ul>
68
+
69
+
### Related Topics
70
+
[[Greedy](../../tag/greedy/README.md)]
71
+
72
+
### Hints
73
+
<details>
74
+
<summary>Hint 1</summary>
75
+
If the s.length < k we cannot construct k strings from s and answer is false.
76
+
</details>
77
+
78
+
<details>
79
+
<summary>Hint 2</summary>
80
+
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.
81
+
</details>
82
+
83
+
<details>
84
+
<summary>Hint 3</summary>
85
+
Otherwise you can construct exactly k palindrome strings and answer is true (why ?).
[< Previous](../customers-who-bought-products-a-and-b-but-not-c"Customers Who Bought Products A and B but Not C")
9
+
10
+
[Next >](../construct-k-palindrome-strings"Construct K Palindrome Strings")
11
+
12
+
## [1399. Count Largest Group (Easy)](https://leetcode.com/problems/count-largest-group"统计最大组的数目")
13
+
14
+
<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>
15
+
16
+
<p>Return how many groups have the largest size.</p>
17
+
18
+
<p> </p>
19
+
<p><strong>Example 1:</strong></p>
20
+
21
+
<pre>
22
+
<strong>Input:</strong> n = 13
23
+
<strong>Output:</strong> 4
24
+
<strong>Explanation:</strong> There are 9 groups in total, they are grouped according sum of its digits of numbers from 1 to 13:
25
+
[1,10], [2,11], [3,12], [4,13], [5], [6], [7], [8], [9]. There are 4 groups with largest size.
26
+
</pre>
27
+
28
+
<p><strong>Example 2:</strong></p>
29
+
30
+
<pre>
31
+
<strong>Input:</strong> n = 2
32
+
<strong>Output:</strong> 2
33
+
<strong>Explanation:</strong> There are 2 groups [1], [2] of size 1.
34
+
</pre>
35
+
36
+
<p><strong>Example 3:</strong></p>
37
+
38
+
<pre>
39
+
<strong>Input:</strong> n = 15
40
+
<strong>Output:</strong> 6
41
+
</pre>
42
+
43
+
<p><strong>Example 4:</strong></p>
44
+
45
+
<pre>
46
+
<strong>Input:</strong> n = 24
47
+
<strong>Output:</strong> 5
48
+
</pre>
49
+
50
+
<p> </p>
51
+
<p><strong>Constraints:</strong></p>
52
+
53
+
<ul>
54
+
<li><code>1 <= n <= 10^4</code></li>
55
+
</ul>
56
+
57
+
### Related Topics
58
+
[[Array](../../tag/array/README.md)]
59
+
60
+
### Hints
61
+
<details>
62
+
<summary>Hint 1</summary>
63
+
Count the digit sum for each integer in the range and find out the largest groups.
undergroundSystem.getAverageTime("Paradise", "Cambridge"); // return 14.0. There was only one travel from "Paradise" (at time 8) to "Cambridge" (at time 22)
59
-
undergroundSystem.getAverageTime("Leyton", "Waterloo"); // return 11.0. There were two travels from "Leyton" to "Waterloo", a customer with id=45 from time=3 to time=15 and a customer with id=27 from time=10 to time=20. So the average time is ( (15-3) + (20-10) ) / 2 = 11.0
58
+
undergroundSystem.getAverageTime("Paradise", "Cambridge"); // return 14.00000. There was only one travel from "Paradise" (at time 8) to "Cambridge" (at time 22)
59
+
undergroundSystem.getAverageTime("Leyton", "Waterloo"); // return 11.00000. There were two travels from "Leyton" to "Waterloo", a customer with id=45 from time=3 to time=15 and a customer with id=27 from time=10 to time=20. So the average time is ( (15-3) + (20-10) ) / 2 = 11.00000
0 commit comments