|
| 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> </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> </p> |
| 39 | +<p><strong>Constraints:</strong></p> |
| 40 | + |
| 41 | +<ul> |
| 42 | + <li><code>n == points.length</code></li> |
| 43 | + <li><code>2 <= n <= 50</code></li> |
| 44 | + <li><code>points[i].length == 2</code></li> |
| 45 | + <li><code>1 <= x<sub>i</sub>, y<sub>i</sub> <= 10<sup>9</sup></code></li> |
| 46 | + <li><code>2 <= k <= 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 --> |
0 commit comments