Skip to content

Commit c1ae93f

Browse files
committed
feat: update lc problem list
1 parent f85d9a0 commit c1ae93f

File tree

9 files changed

+188
-19
lines changed

9 files changed

+188
-19
lines changed
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# [1956. 感染 K 种病毒所需的最短时间](https://leetcode-cn.com/problems/minimum-time-for-k-virus-variants-to-spread)
2+
3+
[English Version](/solution/1900-1999/1956.Minimum%20Time%20For%20K%20Virus%20Variants%20to%20Spread/README_EN.md)
4+
5+
## 题目描述
6+
7+
<!-- 这里写题目描述 -->
8+
9+
<p>在无限大的2维平面上有 <code>n</code> 种不同的病毒。给定二维数组 <code>points</code> ,<span style="">第 </span><code>i</code><span style=""> 项 </span><code>points[i] = [x<sub>i</sub>, y<sub>i</sub>]</code> 说明第 <code>0</code> 天有一种病毒在点 <code>(x<sub>i</sub>, y<sub>i</sub>)</code> 。注意初始状态下,可能有多种病毒在同一点上。</p>
10+
11+
<p>每天,被感染的点会把它感染的病毒传播到上下左右四个邻居点。</p>
12+
13+
<p>现给定一个整数<code>k</code> ,问最少需要多少天,方能找到一点感染至少 <code>k</code> 种病毒?</p>
14+
15+
<p> </p>
16+
17+
<p><strong>示例 1:</strong></p>
18+
19+
<p><strong><img alt="" src="https://cdn.jsdelivr.net/gh/doocs/leetcode@main/solution/1900-1999/1956.Minimum%20Time%20For%20K%20Virus%20Variants%20to%20Spread/images/case-1.png" style="width: 421px; height: 256px;" /></strong></p>
20+
21+
<pre>
22+
<strong>输入:</strong>points = [[1,1],[6,1]], k = 2
23+
<b>输出:</b>3
24+
<strong>解释:</strong>在第3天,点 (3,1) 与 (4,1) 将感染所有2种病毒。
25+
</pre>
26+
27+
<p><strong>示例 2:</strong></p>
28+
29+
<p><strong><img alt="" src="https://cdn.jsdelivr.net/gh/doocs/leetcode@main/solution/1900-1999/1956.Minimum%20Time%20For%20K%20Virus%20Variants%20to%20Spread/images/case-2.png" style="width: 416px; height: 257px;" /></strong></p>
30+
31+
<pre>
32+
<strong>输入:</strong>points = [[3,3],[1,2],[9,2]], k = 2
33+
<b>输出:</b>2
34+
<b>解释:</b>在第2天, 点(1,2), (1,3), (2,1), (2,2), (3,1) 和 (3,3) 将会感染前两种病毒。
35+
</pre>
36+
37+
<p><strong>示例 3:</strong></p>
38+
39+
<p><strong><img alt="" src="https://cdn.jsdelivr.net/gh/doocs/leetcode@main/solution/1900-1999/1956.Minimum%20Time%20For%20K%20Virus%20Variants%20to%20Spread/images/case-2.png" style="width: 416px; height: 257px;" /></strong></p>
40+
41+
<pre>
42+
<b>输入:</b>points = [[3,3],[1,2],[9,2]], k = 3
43+
<b>输出:</b> 4
44+
<strong>解释:</strong>在第4天,点 (5,2) 会感染所有3种病毒。
45+
</pre>
46+
47+
<p> </p>
48+
49+
<p><strong>提示:</strong></p>
50+
51+
<ul>
52+
<li><code>n == points.length</code></li>
53+
<li><code>2 <= n <= 16</code></li>
54+
<li><code>1 <= x<sub>i</sub>, y<sub>i</sub> <= 10<sup>9</sup></code></li>
55+
<li><code>2 <= k <= n</code></li>
56+
</ul>
57+
58+
59+
## 解法
60+
61+
<!-- 这里可写通用的实现逻辑 -->
62+
63+
<!-- tabs:start -->
64+
65+
### **Python3**
66+
67+
<!-- 这里可写当前语言的特殊实现逻辑 -->
68+
69+
```python
70+
71+
```
72+
73+
### **Java**
74+
75+
<!-- 这里可写当前语言的特殊实现逻辑 -->
76+
77+
```java
78+
79+
```
80+
81+
### **...**
82+
83+
```
84+
85+
```
86+
87+
<!-- tabs:end -->
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# [1956. Minimum Time For K Virus Variants to Spread](https://leetcode.com/problems/minimum-time-for-k-virus-variants-to-spread)
2+
3+
[中文文档](/solution/1900-1999/1956.Minimum%20Time%20For%20K%20Virus%20Variants%20to%20Spread/README.md)
4+
5+
## Description
6+
7+
<p>There are <code>n</code> <strong>unique</strong> virus variants in an infinite 2D grid. You are given a 2D array <code>points</code>, where <code>points[i] = [x<sub>i</sub>, y<sub>i</sub>]</code> represents a virus originating at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> on day <code>0</code>. Note that it is possible for <strong>multiple </strong>virus variants to originate at the <strong>same</strong> point.</p>
8+
9+
<p>Every day, each cell infected with a virus variant will spread the virus to <strong>all </strong>neighboring points in the <strong>four</strong> cardinal directions (i.e. up, down, left, and right). If a cell has multiple variants, all the variants will spread without interfering with each other.</p>
10+
11+
<p>Given an integer <code>k</code>, return <em>the <strong>minimum integer</strong> number of days for <strong>any</strong> point to contain <strong>at least</strong> </em><code>k</code><em> of the unique virus variants</em>.</p>
12+
13+
<p>&nbsp;</p>
14+
<p><strong>Example 1:</strong></p>
15+
<img alt="" src="https://cdn.jsdelivr.net/gh/doocs/leetcode@main/solution/1900-1999/1956.Minimum%20Time%20For%20K%20Virus%20Variants%20to%20Spread/images/case-1.png" style="width: 421px; height: 256px;" />
16+
<pre>
17+
<strong>Input:</strong> points = [[1,1],[6,1]], k = 2
18+
<strong>Output:</strong> 3
19+
<strong>Explanation:</strong> On day 3, points (3,1) and (4,1) will contain both virus variants.
20+
</pre>
21+
22+
<p><strong>Example 2:</strong></p>
23+
<img alt="" src="https://cdn.jsdelivr.net/gh/doocs/leetcode@main/solution/1900-1999/1956.Minimum%20Time%20For%20K%20Virus%20Variants%20to%20Spread/images/case-2.png" style="width: 416px; height: 257px;" />
24+
<pre>
25+
<strong>Input:</strong> points = [[3,3],[1,2],[9,2]], k = 2
26+
<strong>Output:</strong> 2
27+
<strong>Explanation:</strong> On day 2, points (1,3), (2,3), (2,2), and (3,2) will contain the first two viruses.
28+
</pre>
29+
30+
<p><strong>Example 3:</strong></p>
31+
<img alt="" src="https://cdn.jsdelivr.net/gh/doocs/leetcode@main/solution/1900-1999/1956.Minimum%20Time%20For%20K%20Virus%20Variants%20to%20Spread/images/case-2.png" style="width: 416px; height: 257px;" />
32+
<pre>
33+
<strong>Input:</strong> points = [[3,3],[1,2],[9,2]], k = 3
34+
<strong>Output:</strong> 4
35+
<strong>Explanation:</strong> On day 4, the point (5,2) will contain all 3 viruses.
36+
</pre>
37+
38+
<p>&nbsp;</p>
39+
<p><strong>Constraints:</strong></p>
40+
41+
<ul>
42+
<li><code>n == points.length</code></li>
43+
<li><code>2 &lt;= n &lt;= 50</code></li>
44+
<li><code>points[i].length == 2</code></li>
45+
<li><code>1 &lt;= x<sub>i</sub>, y<sub>i</sub> &lt;= 10<sup>9</sup></code></li>
46+
<li><code>2 &lt;= k &lt;= n</code></li>
47+
</ul>
48+
49+
50+
## Solutions
51+
52+
<!-- tabs:start -->
53+
54+
### **Python3**
55+
56+
```python
57+
58+
```
59+
60+
### **Java**
61+
62+
```java
63+
64+
```
65+
66+
### **...**
67+
68+
```
69+
70+
```
71+
72+
<!-- tabs:end -->
Loading
Loading

0 commit comments

Comments
 (0)