Skip to content

Commit a85f495

Browse files
acbinidoocs
andauthored
feat: add weekly contest 377 (doocs#2148)
--------- Co-authored-by: Doocs Bot <doocs-bot@outlook.com>
1 parent 6b3553e commit a85f495

File tree

28 files changed

+852
-50
lines changed

28 files changed

+852
-50
lines changed

solution/10000-10099/10031.Count the Number of Incremovable Subarrays I/README.md solution/2900-2999/2970.Count the Number of Incremovable Subarrays I/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# [10031. 统计移除递增子数组的数目 I](https://leetcode.cn/problems/count-the-number-of-incremovable-subarrays-i)
1+
# [2970. 统计移除递增子数组的数目 I](https://leetcode.cn/problems/count-the-number-of-incremovable-subarrays-i)
22

3-
[English Version](/solution/10000-10099/10031.Count%20the%20Number%20of%20Incremovable%20Subarrays%20I/README_EN.md)
3+
[English Version](/solution/2900-2999/2970.Count%20the%20Number%20of%20Incremovable%20Subarrays%20I/README_EN.md)
44

55
## 题目描述
66

solution/10000-10099/10031.Count the Number of Incremovable Subarrays I/README_EN.md solution/2900-2999/2970.Count the Number of Incremovable Subarrays I/README_EN.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# [10031. Count the Number of Incremovable Subarrays I](https://leetcode.com/problems/count-the-number-of-incremovable-subarrays-i)
1+
# [2970. Count the Number of Incremovable Subarrays I](https://leetcode.com/problems/count-the-number-of-incremovable-subarrays-i)
22

3-
[中文文档](/solution/10000-10099/10031.Count%20the%20Number%20of%20Incremovable%20Subarrays%20I/README.md)
3+
[中文文档](/solution/2900-2999/2970.Count%20the%20Number%20of%20Incremovable%20Subarrays%20I/README.md)
44

55
## Description
66

solution/10000-10099/10032.Find Polygon With the Largest Perimeter/README.md solution/2900-2999/2971.Find Polygon With the Largest Perimeter/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# [10032. 找到最大周长的多边形](https://leetcode.cn/problems/find-polygon-with-the-largest-perimeter)
1+
# [2971. 找到最大周长的多边形](https://leetcode.cn/problems/find-polygon-with-the-largest-perimeter)
22

3-
[English Version](/solution/10000-10099/10032.Find%20Polygon%20With%20the%20Largest%20Perimeter/README_EN.md)
3+
[English Version](/solution/2900-2999/2971.Find%20Polygon%20With%20the%20Largest%20Perimeter/README_EN.md)
44

55
## 题目描述
66

solution/10000-10099/10032.Find Polygon With the Largest Perimeter/README_EN.md solution/2900-2999/2971.Find Polygon With the Largest Perimeter/README_EN.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# [10032. Find Polygon With the Largest Perimeter](https://leetcode.com/problems/find-polygon-with-the-largest-perimeter)
1+
# [2971. Find Polygon With the Largest Perimeter](https://leetcode.com/problems/find-polygon-with-the-largest-perimeter)
22

3-
[中文文档](/solution/10000-10099/10032.Find%20Polygon%20With%20the%20Largest%20Perimeter/README.md)
3+
[中文文档](/solution/2900-2999/2971.Find%20Polygon%20With%20the%20Largest%20Perimeter/README.md)
44

55
## Description
66

solution/10000-10099/10033.Count the Number of Incremovable Subarrays II/README.md solution/2900-2999/2972.Count the Number of Incremovable Subarrays II/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# [10033. 统计移除递增子数组的数目 II](https://leetcode.cn/problems/count-the-number-of-incremovable-subarrays-ii)
1+
# [2972. 统计移除递增子数组的数目 II](https://leetcode.cn/problems/count-the-number-of-incremovable-subarrays-ii)
22

3-
[English Version](/solution/10000-10099/10033.Count%20the%20Number%20of%20Incremovable%20Subarrays%20II/README_EN.md)
3+
[English Version](/solution/2900-2999/2972.Count%20the%20Number%20of%20Incremovable%20Subarrays%20II/README_EN.md)
44

55
## 题目描述
66

solution/10000-10099/10033.Count the Number of Incremovable Subarrays II/README_EN.md solution/2900-2999/2972.Count the Number of Incremovable Subarrays II/README_EN.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# [10033. Count the Number of Incremovable Subarrays II](https://leetcode.com/problems/count-the-number-of-incremovable-subarrays-ii)
1+
# [2972. Count the Number of Incremovable Subarrays II](https://leetcode.com/problems/count-the-number-of-incremovable-subarrays-ii)
22

3-
[中文文档](/solution/10000-10099/10033.Count%20the%20Number%20of%20Incremovable%20Subarrays%20II/README.md)
3+
[中文文档](/solution/2900-2999/2972.Count%20the%20Number%20of%20Incremovable%20Subarrays%20II/README.md)
44

55
## Description
66

solution/10000-10099/10034.Find Number of Coins to Place in Tree Nodes/README.md solution/2900-2999/2973.Find Number of Coins to Place in Tree Nodes/README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# [10034. 树中每个节点放置的金币数目](https://leetcode.cn/problems/find-number-of-coins-to-place-in-tree-nodes)
1+
# [2973. 树中每个节点放置的金币数目](https://leetcode.cn/problems/find-number-of-coins-to-place-in-tree-nodes)
22

3-
[English Version](/solution/10000-10099/10034.Find%20Number%20of%20Coins%20to%20Place%20in%20Tree%20Nodes/README_EN.md)
3+
[English Version](/solution/2900-2999/2973.Find%20Number%20of%20Coins%20to%20Place%20in%20Tree%20Nodes/README_EN.md)
44

55
## 题目描述
66

@@ -23,7 +23,7 @@
2323

2424
<p><strong class="example">示例 1:</strong></p>
2525

26-
<p><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/10000-10099/10034.Find%20Number%20of%20Coins%20to%20Place%20in%20Tree%20Nodes/images/screenshot-2023-11-10-012641.png" style="width: 600px; height: 233px;" /></p>
26+
<p><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/2900-2999/2973.Find%20Number%20of%20Coins%20to%20Place%20in%20Tree%20Nodes/images/screenshot-2023-11-10-012641.png" style="width: 600px; height: 233px;" /></p>
2727

2828
<pre>
2929
<b>输入:</b>edges = [[0,1],[0,2],[0,3],[0,4],[0,5]], cost = [1,2,3,4,5,6]
@@ -33,7 +33,7 @@
3333

3434
<p><strong class="example">示例 2:</strong></p>
3535

36-
<p><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/10000-10099/10034.Find%20Number%20of%20Coins%20to%20Place%20in%20Tree%20Nodes/images/screenshot-2023-11-10-012614.png" style="width: 800px; height: 374px;" /></p>
36+
<p><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/2900-2999/2973.Find%20Number%20of%20Coins%20to%20Place%20in%20Tree%20Nodes/images/screenshot-2023-11-10-012614.png" style="width: 800px; height: 374px;" /></p>
3737

3838
<pre>
3939
<b>输入:</b>edges = [[0,1],[0,2],[1,3],[1,4],[1,5],[2,6],[2,7],[2,8]], cost = [1,4,2,3,5,7,8,-4,2]
@@ -47,7 +47,7 @@
4747

4848
<p><strong class="example">示例 3:</strong></p>
4949

50-
<p><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/10000-10099/10034.Find%20Number%20of%20Coins%20to%20Place%20in%20Tree%20Nodes/images/screenshot-2023-11-10-012513.png" style="width: 300px; height: 277px;" /></p>
50+
<p><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/2900-2999/2973.Find%20Number%20of%20Coins%20to%20Place%20in%20Tree%20Nodes/images/screenshot-2023-11-10-012513.png" style="width: 300px; height: 277px;" /></p>
5151

5252
<pre>
5353
<b>输入:</b>edges = [[0,1],[0,2]], cost = [1,2,-2]

solution/10000-10099/10034.Find Number of Coins to Place in Tree Nodes/README_EN.md solution/2900-2999/2973.Find Number of Coins to Place in Tree Nodes/README_EN.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# [10034. Find Number of Coins to Place in Tree Nodes](https://leetcode.com/problems/find-number-of-coins-to-place-in-tree-nodes)
1+
# [2973. Find Number of Coins to Place in Tree Nodes](https://leetcode.com/problems/find-number-of-coins-to-place-in-tree-nodes)
22

3-
[中文文档](/solution/10000-10099/10034.Find%20Number%20of%20Coins%20to%20Place%20in%20Tree%20Nodes/README.md)
3+
[中文文档](/solution/2900-2999/2973.Find%20Number%20of%20Coins%20to%20Place%20in%20Tree%20Nodes/README.md)
44

55
## Description
66

@@ -19,15 +19,15 @@
1919

2020
<p>&nbsp;</p>
2121
<p><strong class="example">Example 1:</strong></p>
22-
<img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/10000-10099/10034.Find%20Number%20of%20Coins%20to%20Place%20in%20Tree%20Nodes/images/screenshot-2023-11-10-012641.png" style="width: 600px; height: 233px;" />
22+
<img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/2900-2999/2973.Find%20Number%20of%20Coins%20to%20Place%20in%20Tree%20Nodes/images/screenshot-2023-11-10-012641.png" style="width: 600px; height: 233px;" />
2323
<pre>
2424
<strong>Input:</strong> edges = [[0,1],[0,2],[0,3],[0,4],[0,5]], cost = [1,2,3,4,5,6]
2525
<strong>Output:</strong> [120,1,1,1,1,1]
2626
<strong>Explanation:</strong> For node 0 place 6 * 5 * 4 = 120 coins. All other nodes are leaves with subtree of size 1, place 1 coin on each of them.
2727
</pre>
2828

2929
<p><strong class="example">Example 2:</strong></p>
30-
<img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/10000-10099/10034.Find%20Number%20of%20Coins%20to%20Place%20in%20Tree%20Nodes/images/screenshot-2023-11-10-012614.png" style="width: 800px; height: 374px;" />
30+
<img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/2900-2999/2973.Find%20Number%20of%20Coins%20to%20Place%20in%20Tree%20Nodes/images/screenshot-2023-11-10-012614.png" style="width: 800px; height: 374px;" />
3131
<pre>
3232
<strong>Input:</strong> edges = [[0,1],[0,2],[1,3],[1,4],[1,5],[2,6],[2,7],[2,8]], cost = [1,4,2,3,5,7,8,-4,2]
3333
<strong>Output:</strong> [280,140,32,1,1,1,1,1,1]
@@ -39,7 +39,7 @@
3939
</pre>
4040

4141
<p><strong class="example">Example 3:</strong></p>
42-
<img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/10000-10099/10034.Find%20Number%20of%20Coins%20to%20Place%20in%20Tree%20Nodes/images/screenshot-2023-11-10-012513.png" style="width: 300px; height: 277px;" />
42+
<img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/2900-2999/2973.Find%20Number%20of%20Coins%20to%20Place%20in%20Tree%20Nodes/images/screenshot-2023-11-10-012513.png" style="width: 300px; height: 277px;" />
4343
<pre>
4444
<strong>Input:</strong> edges = [[0,1],[0,2]], cost = [1,2,-2]
4545
<strong>Output:</strong> [0,1,1]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# [2974. 最小数字游戏](https://leetcode.cn/problems/minimum-number-game)
2+
3+
[English Version](/solution/2900-2999/2974.Minimum%20Number%20Game/README_EN.md)
4+
5+
## 题目描述
6+
7+
<!-- 这里写题目描述 -->
8+
9+
<p>你有一个下标从 <strong>0</strong> 开始、长度为 <strong>偶数</strong> 的整数数组 <code>nums</code> ,同时还有一个空数组 <code>arr</code> 。Alice 和 Bob 决定玩一个游戏,游戏中每一轮 Alice 和 Bob 都会各自执行一次操作。游戏规则如下:</p>
10+
11+
<ul>
12+
<li>每一轮,Alice 先从 <code>nums</code> 中移除一个<strong> 最小</strong> 元素,然后 Bob 执行同样的操作。</li>
13+
<li>接着,Bob 会将移除的元素添加到数组 <code>arr</code> 中,然后 Alice 也执行同样的操作。</li>
14+
<li>游戏持续进行,直到 <code>nums</code> 变为空。</li>
15+
</ul>
16+
17+
<p>返回结果数组 <code>arr</code> 。</p>
18+
19+
<p>&nbsp;</p>
20+
21+
<p><strong class="example">示例 1:</strong></p>
22+
23+
<pre>
24+
<strong>输入:</strong>nums = [5,4,2,3]
25+
<strong>输出:</strong>[3,2,5,4]
26+
<strong>解释:</strong>第一轮,Alice 先移除 2 ,然后 Bob 移除 3 。然后 Bob 先将 3 添加到 arr 中,接着 Alice 再将 2 添加到 arr 中。于是 arr = [3,2] 。
27+
第二轮开始时,nums = [5,4] 。Alice 先移除 4 ,然后 Bob 移除 5 。接着他们都将元素添加到 arr 中,arr 变为 [3,2,5,4] 。
28+
</pre>
29+
30+
<p><strong class="example">示例 2:</strong></p>
31+
32+
<pre>
33+
<strong>输入:</strong>nums = [2,5]
34+
<strong>输出:</strong>[5,2]
35+
<strong>解释:</strong>第一轮,Alice 先移除 2 ,然后 Bob 移除 5 。然后 Bob 先将 5 添加到 arr 中,接着 Alice 再将 2 添加到 arr 中。于是 arr = [5,2] 。
36+
</pre>
37+
38+
<p>&nbsp;</p>
39+
40+
<p><strong>提示:</strong></p>
41+
42+
<ul>
43+
<li><code>1 &lt;= nums.length &lt;= 100</code></li>
44+
<li><code>1 &lt;= nums[i] &lt;= 100</code></li>
45+
<li><code>nums.length % 2 == 0</code></li>
46+
</ul>
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+
### **C++**
71+
72+
```cpp
73+
74+
```
75+
76+
### **Go**
77+
78+
```go
79+
80+
```
81+
82+
### **...**
83+
84+
```
85+
86+
```
87+
88+
<!-- tabs:end -->
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# [2974. Minimum Number Game](https://leetcode.com/problems/minimum-number-game)
2+
3+
[中文文档](/solution/2900-2999/2974.Minimum%20Number%20Game/README.md)
4+
5+
## Description
6+
7+
<p>You are given a <strong>0-indexed</strong> integer array <code>nums</code> of <strong>even</strong> length and there is also an empty array <code>arr</code>. Alice and Bob decided to play a game where in every round Alice and Bob will do one move. The rules of the game are as follows:</p>
8+
9+
<ul>
10+
<li>Every round, first Alice will remove the <strong>minimum</strong> element from <code>nums</code>, and then Bob does the same.</li>
11+
<li>Now, first Bob will append the removed element in the array <code>arr</code>, and then Alice does the same.</li>
12+
<li>The game continues until <code>nums</code> becomes empty.</li>
13+
</ul>
14+
15+
<p>Return <em>the resulting array </em><code>arr</code>.</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,2,3]
22+
<strong>Output:</strong> [3,2,5,4]
23+
<strong>Explanation:</strong> In round one, first Alice removes 2 and then Bob removes 3. Then in arr firstly Bob appends 3 and then Alice appends 2. So arr = [3,2].
24+
At the begining of round two, nums = [5,4]. Now, first Alice removes 4 and then Bob removes 5. Then both append in arr which becomes [3,2,5,4].
25+
</pre>
26+
27+
<p><strong class="example">Example 2:</strong></p>
28+
29+
<pre>
30+
<strong>Input:</strong> nums = [2,5]
31+
<strong>Output:</strong> [5,2]
32+
<strong>Explanation:</strong> In round one, first Alice removes 2 and then Bob removes 5. Then in arr firstly Bob appends and then Alice appends. So arr = [5,2].
33+
</pre>
34+
35+
<p>&nbsp;</p>
36+
<p><strong>Constraints:</strong></p>
37+
38+
<ul>
39+
<li><code>1 &lt;= nums.length &lt;= 100</code></li>
40+
<li><code>1 &lt;= nums[i] &lt;= 100</code></li>
41+
<li><code>nums.length % 2 == 0</code></li>
42+
</ul>
43+
44+
## Solutions
45+
46+
<!-- tabs:start -->
47+
48+
### **Python3**
49+
50+
```python
51+
52+
```
53+
54+
### **Java**
55+
56+
```java
57+
58+
```
59+
60+
### **C++**
61+
62+
```cpp
63+
64+
```
65+
66+
### **Go**
67+
68+
```go
69+
70+
```
71+
72+
### **...**
73+
74+
```
75+
76+
```
77+
78+
<!-- tabs:end -->
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# [2975. 移除栅栏得到的正方形田地的最大面积](https://leetcode.cn/problems/maximum-square-area-by-removing-fences-from-a-field)
2+
3+
[English Version](/solution/2900-2999/2975.Maximum%20Square%20Area%20by%20Removing%20Fences%20From%20a%20Field/README_EN.md)
4+
5+
## 题目描述
6+
7+
<!-- 这里写题目描述 -->
8+
9+
<p>有一个大型的 <code>(m - 1) x (n - 1)</code> 矩形田地,其两个对角分别是 <code>(1, 1)</code> 和 <code>(m, n)</code> ,田地内部有一些水平栅栏和垂直栅栏,分别由数组 <code>hFences</code> 和 <code>vFences</code> 给出。</p>
10+
11+
<p>水平栅栏为坐标 <code>(hFences[i], 1)</code> 到 <code>(hFences[i], n)</code>,垂直栅栏为坐标 <code>(1, vFences[i])</code> 到 <code>(m, vFences[i])</code> 。</p>
12+
13+
<p>返回通过<strong> 移除 </strong>一些栅栏(<strong>可能不移除</strong>)所能形成的最大面积的<strong> 正方形 </strong>田地的面积,或者如果无法形成正方形田地则返回 <code>-1</code>。</p>
14+
15+
<p>由于答案可能很大,所以请返回结果对 <code>10<sup>9</sup> + 7</code> <strong>取余</strong> 后的值。</p>
16+
17+
<p><strong>注意:</strong>田地外围两个水平栅栏(坐标 <code>(1, 1)</code> 到 <code>(1, n)</code> 和坐标 <code>(m, 1)</code> 到 <code>(m, n)</code> )以及两个垂直栅栏(坐标 <code>(1, 1)</code> 到 <code>(m, 1)</code> 和坐标 <code>(1, n)</code> 到 <code>(m, n)</code> )所包围。这些栅栏<strong> 不能</strong> 被移除。</p>
18+
19+
<p>&nbsp;</p>
20+
21+
<p><strong class="example">示例 1:</strong></p>
22+
23+
<p><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/2900-2999/2975.Maximum%20Square%20Area%20by%20Removing%20Fences%20From%20a%20Field/images/screenshot-from-2023-11-05-22-40-25.png" /></p>
24+
25+
<pre>
26+
<strong>输入:</strong>m = 4, n = 3, hFences = [2,3], vFences = [2]
27+
<strong>输出:</strong>4
28+
<strong>解释:</strong>移除位于 2 的水平栅栏和位于 2 的垂直栅栏将得到一个面积为 4 的正方形田地。
29+
</pre>
30+
31+
<p><strong class="example">示例 2:</strong></p>
32+
33+
<p><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/2900-2999/2975.Maximum%20Square%20Area%20by%20Removing%20Fences%20From%20a%20Field/images/maxsquareareaexample1.png" style="width: 285px; height: 242px;" /></p>
34+
35+
<pre>
36+
<strong>输入:</strong>m = 6, n = 7, hFences = [2], vFences = [4]
37+
<strong>输出:</strong>-1
38+
<strong>解释:</strong>可以证明无法通过移除栅栏形成正方形田地。
39+
</pre>
40+
41+
<p>&nbsp;</p>
42+
43+
<p><strong>提示:</strong></p>
44+
45+
<ul>
46+
<li><code>3 &lt;= m, n &lt;= 10<sup>9</sup></code></li>
47+
<li><code>1 &lt;= hFences.length, vFences.length &lt;= 600</code></li>
48+
<li><code>1 &lt; hFences[i] &lt; m</code></li>
49+
<li><code>1 &lt; vFences[i] &lt; n</code></li>
50+
<li><code>hFences</code> 和 <code>vFences</code> 中的元素是唯一的。</li>
51+
</ul>
52+
53+
## 解法
54+
55+
<!-- 这里可写通用的实现逻辑 -->
56+
57+
<!-- tabs:start -->
58+
59+
### **Python3**
60+
61+
<!-- 这里可写当前语言的特殊实现逻辑 -->
62+
63+
```python
64+
65+
```
66+
67+
### **Java**
68+
69+
<!-- 这里可写当前语言的特殊实现逻辑 -->
70+
71+
```java
72+
73+
```
74+
75+
### **C++**
76+
77+
```cpp
78+
79+
```
80+
81+
### **Go**
82+
83+
```go
84+
85+
```
86+
87+
### **...**
88+
89+
```
90+
91+
```
92+
93+
<!-- tabs:end -->

0 commit comments

Comments
 (0)