Skip to content

Commit 0e1c776

Browse files
committed
feat: add new lc problem and update summary
1 parent b1e3d8c commit 0e1c776

File tree

9 files changed

+176
-30
lines changed

9 files changed

+176
-30
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# [1924. Erect the Fence II](https://leetcode-cn.com/problems/erect-the-fence-ii)
2+
3+
[English Version](/solution/1900-1999/1924.Erect%20the%20Fence%20II/README_EN.md)
4+
5+
## 题目描述
6+
7+
<!-- 这里写题目描述 -->
8+
9+
<p>You are given a 2D integer array <code>trees</code> where <code>trees[i] = [x<sub>i</sub>, y<sub>i</sub>]</code> represents the location of the <code>i<sup>th</sup></code> tree in the garden.</p>
10+
11+
<p>You are asked to fence the entire garden using the minimum length of rope possible. The garden is well-fenced only if <strong>all the trees are enclosed</strong> and the rope used <strong>forms a perfect circle</strong>. A tree is considered enclosed if it is inside or on the border of the circle.</p>
12+
13+
<p>More formally, you must form a circle using the rope with a center <code>(x, y)</code> and radius <code>r</code> where all trees lie inside or on the circle and <code>r</code> is <strong>minimum</strong>.</p>
14+
15+
<p>Return <em>the center and radius of the circle as a length 3 array </em><code>[x, y, r]</code><em>.</em>&nbsp;Answers within <code>10<sup>-5</sup></code> of the actual answer will be accepted.</p>
16+
17+
<p>&nbsp;</p>
18+
<p><strong>Example 1:</strong></p>
19+
20+
<p><strong><img alt="" src="https://cdn.jsdelivr.net/gh/doocs/leetcode@main/solution/1900-1999/1924.Erect%20the%20Fence%20II/images/trees1.png" style="width: 510px; height: 501px;" /></strong></p>
21+
22+
<pre>
23+
<strong>Input:</strong> trees = [[1,1],[2,2],[2,0],[2,4],[3,3],[4,2]]
24+
<strong>Output:</strong> [2.00000,2.00000,2.00000]
25+
<strong>Explanation:</strong> The fence will have center = (2, 2) and radius = 2
26+
</pre>
27+
28+
<p><strong>Example 2:</strong></p>
29+
30+
<p><strong><img alt="" src="https://cdn.jsdelivr.net/gh/doocs/leetcode@main/solution/1900-1999/1924.Erect%20the%20Fence%20II/images/trees2.png" style="width: 510px; height: 501px;" /></strong></p>
31+
32+
<pre>
33+
<strong>Input:</strong> trees = [[1,2],[2,2],[4,2]]
34+
<strong>Output:</strong> [2.50000,2.00000,1.50000]
35+
<strong>Explanation:</strong> The fence will have center = (2.5, 2) and radius = 1.5
36+
</pre>
37+
38+
<p>&nbsp;</p>
39+
<p><strong>Constraints:</strong></p>
40+
41+
<ul>
42+
<li><code>1 &lt;= trees.length &lt;= 3000</code></li>
43+
<li><code>trees[i].length == 2</code></li>
44+
<li><code>0 &lt;= x<sub>i</sub>, y<sub>i</sub> &lt;= 3000</code></li>
45+
</ul>
46+
47+
48+
## 解法
49+
50+
<!-- 这里可写通用的实现逻辑 -->
51+
52+
<!-- tabs:start -->
53+
54+
### **Python3**
55+
56+
<!-- 这里可写当前语言的特殊实现逻辑 -->
57+
58+
```python
59+
60+
```
61+
62+
### **Java**
63+
64+
<!-- 这里可写当前语言的特殊实现逻辑 -->
65+
66+
```java
67+
68+
```
69+
70+
### **...**
71+
72+
```
73+
74+
```
75+
76+
<!-- tabs:end -->
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# [1924. Erect the Fence II](https://leetcode.com/problems/erect-the-fence-ii)
2+
3+
[中文文档](/solution/1900-1999/1924.Erect%20the%20Fence%20II/README.md)
4+
5+
## Description
6+
7+
<p>You are given a 2D integer array <code>trees</code> where <code>trees[i] = [x<sub>i</sub>, y<sub>i</sub>]</code> represents the location of the <code>i<sup>th</sup></code> tree in the garden.</p>
8+
9+
<p>You are asked to fence the entire garden using the minimum length of rope possible. The garden is well-fenced only if <strong>all the trees are enclosed</strong> and the rope used <strong>forms a perfect circle</strong>. A tree is considered enclosed if it is inside or on the border of the circle.</p>
10+
11+
<p>More formally, you must form a circle using the rope with a center <code>(x, y)</code> and radius <code>r</code> where all trees lie inside or on the circle and <code>r</code> is <strong>minimum</strong>.</p>
12+
13+
<p>Return <em>the center and radius of the circle as a length 3 array </em><code>[x, y, r]</code><em>.</em>&nbsp;Answers within <code>10<sup>-5</sup></code> of the actual answer will be accepted.</p>
14+
15+
<p>&nbsp;</p>
16+
<p><strong>Example 1:</strong></p>
17+
18+
<p><strong><img alt="" src="https://cdn.jsdelivr.net/gh/doocs/leetcode@main/solution/1900-1999/1924.Erect%20the%20Fence%20II/images/trees1.png" style="width: 510px; height: 501px;" /></strong></p>
19+
20+
<pre>
21+
<strong>Input:</strong> trees = [[1,1],[2,2],[2,0],[2,4],[3,3],[4,2]]
22+
<strong>Output:</strong> [2.00000,2.00000,2.00000]
23+
<strong>Explanation:</strong> The fence will have center = (2, 2) and radius = 2
24+
</pre>
25+
26+
<p><strong>Example 2:</strong></p>
27+
28+
<p><strong><img alt="" src="https://cdn.jsdelivr.net/gh/doocs/leetcode@main/solution/1900-1999/1924.Erect%20the%20Fence%20II/images/trees2.png" style="width: 510px; height: 501px;" /></strong></p>
29+
30+
<pre>
31+
<strong>Input:</strong> trees = [[1,2],[2,2],[4,2]]
32+
<strong>Output:</strong> [2.50000,2.00000,1.50000]
33+
<strong>Explanation:</strong> The fence will have center = (2.5, 2) and radius = 1.5
34+
</pre>
35+
36+
<p>&nbsp;</p>
37+
<p><strong>Constraints:</strong></p>
38+
39+
<ul>
40+
<li><code>1 &lt;= trees.length &lt;= 3000</code></li>
41+
<li><code>trees[i].length == 2</code></li>
42+
<li><code>0 &lt;= x<sub>i</sub>, y<sub>i</sub> &lt;= 3000</code></li>
43+
</ul>
44+
45+
46+
## Solutions
47+
48+
<!-- tabs:start -->
49+
50+
### **Python3**
51+
52+
```python
53+
54+
```
55+
56+
### **Java**
57+
58+
```java
59+
60+
```
61+
62+
### **...**
63+
64+
```
65+
66+
```
67+
68+
<!-- tabs:end -->
Loading
Loading

0 commit comments

Comments
 (0)