Skip to content

Commit feefabb

Browse files
committed
feat: update lc problems
1 parent 389f0d3 commit feefabb

File tree

9 files changed

+236
-58
lines changed

9 files changed

+236
-58
lines changed

solution/1900-1999/1989.Maximum Number of People That Can Be Caught in Tag/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
<strong>输入:</strong> team = [0], dist = 1
4242
<strong>输出:</strong> 0
4343
<strong>解释:
44-
</strong>没有 “鬼” 来zh
44+
</strong>没有 “鬼” 来抓人。
4545
</pre>
4646

4747
<p>&nbsp;</p>

solution/2600-2699/2614.Prime In Diagonal/README_EN.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66

77
<p>You are given a 0-indexed two-dimensional integer array <code>nums</code>.</p>
88

9-
<p>Return <em>the largest <strong>prime</strong> number that lies on at least one of the <b>diagonals</b> of </em><code>nums</code>. In case, no prime is present on any of the diagonals, <em>return 0.</em></p>
9+
<p>Return <em>the largest <strong>prime</strong> number that lies on at least one of the <b>diagonals</b> of </em><code>nums</code>. In case, no prime is present on any of the diagonals, return<em> 0.</em></p>
1010

1111
<p>Note that:</p>
1212

1313
<ul>
1414
<li>An integer is <strong>prime</strong> if it is greater than <code>1</code> and has no positive integer divisors other than <code>1</code> and itself.</li>
15-
<li>An integer <code>val</code> is on one of the<strong>diagonals</strong> of <code>nums</code> if there exists an integer <code>i</code> for which <code>nums[i][i] = val</code> or an <code>i</code> for which <code>nums[i][nums.length - i - 1]= val</code>.</li>
15+
<li>An integer <code>val</code> is on one of the <strong>diagonals</strong> of <code>nums</code> if there exists an integer <code>i</code> for which <code>nums[i][i] = val</code> or an <code>i</code> for which <code>nums[i][nums.length - i - 1] = val</code>.</li>
1616
</ul>
1717

1818
<p><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/2600-2699/2614.Prime%20In%20Diagonal/images/screenshot-2023-03-06-at-45648-pm.png" style="width: 181px; height: 121px;" /></p>

solution/2600-2699/2616.Minimize the Maximum Difference of Pairs/README_EN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
<p>Note that for a pair of elements at the index <code>i</code> and <code>j</code>, the difference of this pair is <code>|nums[i] - nums[j]|</code>, where <code>|x|</code> represents the <strong>absolute</strong> <strong>value</strong> of <code>x</code>.</p>
1010

11-
<p>Return <em>the <strong>minimum</strong> <strong>maximum</strong> difference among all </em><code>p</code> <em>pairs.</em></p>
11+
<p>Return <em>the <strong>minimum</strong> <strong>maximum</strong> difference among all </em><code>p</code> <em>pairs.</em> We define the maximum of an empty set to be zero.</p>
1212

1313
<p>&nbsp;</p>
1414
<p><strong class="example">Example 1:</strong></p>
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# [2638. Count the Number of K-Free Subsets](https://leetcode.cn/problems/count-the-number-of-k-free-subsets)
2+
3+
[English Version](/solution/2600-2699/2638.Count%20the%20Number%20of%20K-Free%20Subsets/README_EN.md)
4+
5+
## 题目描述
6+
7+
<!-- 这里写题目描述 -->
8+
9+
<p>You are given an integer array <code>nums</code>,&nbsp;which contains <strong>distinct</strong> elements and an integer <code>k</code>.</p>
10+
11+
<p>A subset is called a <strong>k-Free</strong> subset if it contains <strong>no</strong> two elements with an absolute difference equal to <code>k</code>. Notice that the empty set is a <strong>k-Free</strong> subset.</p>
12+
13+
<p>Return <em>the number of <strong>k-Free</strong> subsets of </em><code>nums</code>.</p>
14+
15+
<p>A <b>subset</b> of an array is a selection of elements (possibly none) of the array.</p>
16+
17+
<p>&nbsp;</p>
18+
<p><strong class="example">Example 1:</strong></p>
19+
20+
<pre>
21+
<strong>Input:</strong> nums = [5,4,6], k = 1
22+
<strong>Output:</strong> 5
23+
<strong>Explanation:</strong> There are 5 valid subsets: {}, {5}, {4}, {6} and {4, 6}.
24+
</pre>
25+
26+
<p><strong class="example">Example 2:</strong></p>
27+
28+
<pre>
29+
<strong>Input:</strong> nums = [2,3,5,8], k = 5
30+
<strong>Output:</strong> 12
31+
<strong>Explanation:</strong> There are 12 valid subsets: {}, {2}, {3}, {5}, {8}, {2, 3}, {2, 3, 5}, {2, 5}, {2, 5, 8}, {2, 8}, {3, 5} and {5, 8}.
32+
</pre>
33+
34+
<p><strong class="example">Example 3:</strong></p>
35+
36+
<pre>
37+
<strong>Input:</strong> nums = [10,5,9,11], k = 20
38+
<strong>Output:</strong> 16
39+
<strong>Explanation:</strong> All subsets are valid. Since the total count of subsets is 2<sup>4 </sup>= 16, so the answer is 16.
40+
</pre>
41+
42+
<p>&nbsp;</p>
43+
<p><strong>Constraints:</strong></p>
44+
45+
<ul>
46+
<li><code>1 &lt;= nums.length &lt;= 50</code></li>
47+
<li><code>1 &lt;= nums[i] &lt;= 1000</code></li>
48+
<li><code>1 &lt;= k &lt;= 1000</code></li>
49+
</ul>
50+
51+
## 解法
52+
53+
<!-- 这里可写通用的实现逻辑 -->
54+
55+
<!-- tabs:start -->
56+
57+
### **Python3**
58+
59+
<!-- 这里可写当前语言的特殊实现逻辑 -->
60+
61+
```python
62+
63+
```
64+
65+
### **Java**
66+
67+
<!-- 这里可写当前语言的特殊实现逻辑 -->
68+
69+
```java
70+
71+
```
72+
73+
### **C++**
74+
75+
```cpp
76+
77+
```
78+
79+
### **Go**
80+
81+
```go
82+
83+
```
84+
85+
### **...**
86+
87+
```
88+
89+
```
90+
91+
<!-- tabs:end -->
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# [2638. Count the Number of K-Free Subsets](https://leetcode.com/problems/count-the-number-of-k-free-subsets)
2+
3+
[中文文档](/solution/2600-2699/2638.Count%20the%20Number%20of%20K-Free%20Subsets/README.md)
4+
5+
## Description
6+
7+
<p>You are given an integer array <code>nums</code>,&nbsp;which contains <strong>distinct</strong> elements and an integer <code>k</code>.</p>
8+
9+
<p>A subset is called a <strong>k-Free</strong> subset if it contains <strong>no</strong> two elements with an absolute difference equal to <code>k</code>. Notice that the empty set is a <strong>k-Free</strong> subset.</p>
10+
11+
<p>Return <em>the number of <strong>k-Free</strong> subsets of </em><code>nums</code>.</p>
12+
13+
<p>A <b>subset</b> of an array is a selection of elements (possibly none) of the array.</p>
14+
15+
<p>&nbsp;</p>
16+
<p><strong class="example">Example 1:</strong></p>
17+
18+
<pre>
19+
<strong>Input:</strong> nums = [5,4,6], k = 1
20+
<strong>Output:</strong> 5
21+
<strong>Explanation:</strong> There are 5 valid subsets: {}, {5}, {4}, {6} and {4, 6}.
22+
</pre>
23+
24+
<p><strong class="example">Example 2:</strong></p>
25+
26+
<pre>
27+
<strong>Input:</strong> nums = [2,3,5,8], k = 5
28+
<strong>Output:</strong> 12
29+
<strong>Explanation:</strong> There are 12 valid subsets: {}, {2}, {3}, {5}, {8}, {2, 3}, {2, 3, 5}, {2, 5}, {2, 5, 8}, {2, 8}, {3, 5} and {5, 8}.
30+
</pre>
31+
32+
<p><strong class="example">Example 3:</strong></p>
33+
34+
<pre>
35+
<strong>Input:</strong> nums = [10,5,9,11], k = 20
36+
<strong>Output:</strong> 16
37+
<strong>Explanation:</strong> All subsets are valid. Since the total count of subsets is 2<sup>4 </sup>= 16, so the answer is 16.
38+
</pre>
39+
40+
<p>&nbsp;</p>
41+
<p><strong>Constraints:</strong></p>
42+
43+
<ul>
44+
<li><code>1 &lt;= nums.length &lt;= 50</code></li>
45+
<li><code>1 &lt;= nums[i] &lt;= 1000</code></li>
46+
<li><code>1 &lt;= k &lt;= 1000</code></li>
47+
</ul>
48+
49+
## Solutions
50+
51+
<!-- tabs:start -->
52+
53+
### **Python3**
54+
55+
```python
56+
57+
```
58+
59+
### **Java**
60+
61+
```java
62+
63+
```
64+
65+
### **C++**
66+
67+
```cpp
68+
69+
```
70+
71+
### **Go**
72+
73+
```go
74+
75+
```
76+
77+
### **...**
78+
79+
```
80+
81+
```
82+
83+
<!-- tabs:end -->

0 commit comments

Comments
 (0)