-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add weekly contest 377 (#2148)
--------- Co-authored-by: Doocs Bot <[email protected]>
- Loading branch information
Showing
28 changed files
with
852 additions
and
50 deletions.
There are no files selected for viewing
4 changes: 2 additions & 2 deletions
4
...ber of Incremovable Subarrays I/README.md → ...ber of Incremovable Subarrays I/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
... of Incremovable Subarrays I/README_EN.md → ... of Incremovable Subarrays I/README_EN.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...ygon With the Largest Perimeter/README.md → ...ygon With the Largest Perimeter/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...n With the Largest Perimeter/README_EN.md → ...n With the Largest Perimeter/README_EN.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...er of Incremovable Subarrays II/README.md → ...er of Incremovable Subarrays II/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...of Incremovable Subarrays II/README_EN.md → ...of Incremovable Subarrays II/README_EN.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes
File renamed without changes
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
# [2974. 最小数字游戏](https://leetcode.cn/problems/minimum-number-game) | ||
|
||
[English Version](/solution/2900-2999/2974.Minimum%20Number%20Game/README_EN.md) | ||
|
||
## 题目描述 | ||
|
||
<!-- 这里写题目描述 --> | ||
|
||
<p>你有一个下标从 <strong>0</strong> 开始、长度为 <strong>偶数</strong> 的整数数组 <code>nums</code> ,同时还有一个空数组 <code>arr</code> 。Alice 和 Bob 决定玩一个游戏,游戏中每一轮 Alice 和 Bob 都会各自执行一次操作。游戏规则如下:</p> | ||
|
||
<ul> | ||
<li>每一轮,Alice 先从 <code>nums</code> 中移除一个<strong> 最小</strong> 元素,然后 Bob 执行同样的操作。</li> | ||
<li>接着,Bob 会将移除的元素添加到数组 <code>arr</code> 中,然后 Alice 也执行同样的操作。</li> | ||
<li>游戏持续进行,直到 <code>nums</code> 变为空。</li> | ||
</ul> | ||
|
||
<p>返回结果数组 <code>arr</code> 。</p> | ||
|
||
<p> </p> | ||
|
||
<p><strong class="example">示例 1:</strong></p> | ||
|
||
<pre> | ||
<strong>输入:</strong>nums = [5,4,2,3] | ||
<strong>输出:</strong>[3,2,5,4] | ||
<strong>解释:</strong>第一轮,Alice 先移除 2 ,然后 Bob 移除 3 。然后 Bob 先将 3 添加到 arr 中,接着 Alice 再将 2 添加到 arr 中。于是 arr = [3,2] 。 | ||
第二轮开始时,nums = [5,4] 。Alice 先移除 4 ,然后 Bob 移除 5 。接着他们都将元素添加到 arr 中,arr 变为 [3,2,5,4] 。 | ||
</pre> | ||
|
||
<p><strong class="example">示例 2:</strong></p> | ||
|
||
<pre> | ||
<strong>输入:</strong>nums = [2,5] | ||
<strong>输出:</strong>[5,2] | ||
<strong>解释:</strong>第一轮,Alice 先移除 2 ,然后 Bob 移除 5 。然后 Bob 先将 5 添加到 arr 中,接着 Alice 再将 2 添加到 arr 中。于是 arr = [5,2] 。 | ||
</pre> | ||
|
||
<p> </p> | ||
|
||
<p><strong>提示:</strong></p> | ||
|
||
<ul> | ||
<li><code>1 <= nums.length <= 100</code></li> | ||
<li><code>1 <= nums[i] <= 100</code></li> | ||
<li><code>nums.length % 2 == 0</code></li> | ||
</ul> | ||
|
||
## 解法 | ||
|
||
<!-- 这里可写通用的实现逻辑 --> | ||
|
||
<!-- tabs:start --> | ||
|
||
### **Python3** | ||
|
||
<!-- 这里可写当前语言的特殊实现逻辑 --> | ||
|
||
```python | ||
|
||
``` | ||
|
||
### **Java** | ||
|
||
<!-- 这里可写当前语言的特殊实现逻辑 --> | ||
|
||
```java | ||
|
||
``` | ||
|
||
### **C++** | ||
|
||
```cpp | ||
|
||
``` | ||
|
||
### **Go** | ||
|
||
```go | ||
|
||
``` | ||
|
||
### **...** | ||
|
||
``` | ||
``` | ||
|
||
<!-- tabs:end --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# [2974. Minimum Number Game](https://leetcode.com/problems/minimum-number-game) | ||
|
||
[中文文档](/solution/2900-2999/2974.Minimum%20Number%20Game/README.md) | ||
|
||
## Description | ||
|
||
<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> | ||
|
||
<ul> | ||
<li>Every round, first Alice will remove the <strong>minimum</strong> element from <code>nums</code>, and then Bob does the same.</li> | ||
<li>Now, first Bob will append the removed element in the array <code>arr</code>, and then Alice does the same.</li> | ||
<li>The game continues until <code>nums</code> becomes empty.</li> | ||
</ul> | ||
|
||
<p>Return <em>the resulting array </em><code>arr</code>.</p> | ||
|
||
<p> </p> | ||
<p><strong class="example">Example 1:</strong></p> | ||
|
||
<pre> | ||
<strong>Input:</strong> nums = [5,4,2,3] | ||
<strong>Output:</strong> [3,2,5,4] | ||
<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]. | ||
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]. | ||
</pre> | ||
|
||
<p><strong class="example">Example 2:</strong></p> | ||
|
||
<pre> | ||
<strong>Input:</strong> nums = [2,5] | ||
<strong>Output:</strong> [5,2] | ||
<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]. | ||
</pre> | ||
|
||
<p> </p> | ||
<p><strong>Constraints:</strong></p> | ||
|
||
<ul> | ||
<li><code>1 <= nums.length <= 100</code></li> | ||
<li><code>1 <= nums[i] <= 100</code></li> | ||
<li><code>nums.length % 2 == 0</code></li> | ||
</ul> | ||
|
||
## Solutions | ||
|
||
<!-- tabs:start --> | ||
|
||
### **Python3** | ||
|
||
```python | ||
|
||
``` | ||
|
||
### **Java** | ||
|
||
```java | ||
|
||
``` | ||
|
||
### **C++** | ||
|
||
```cpp | ||
|
||
``` | ||
|
||
### **Go** | ||
|
||
```go | ||
|
||
``` | ||
|
||
### **...** | ||
|
||
``` | ||
``` | ||
|
||
<!-- tabs:end --> |
93 changes: 93 additions & 0 deletions
93
...on/2900-2999/2975.Maximum Square Area by Removing Fences From a Field/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
# [2975. 移除栅栏得到的正方形田地的最大面积](https://leetcode.cn/problems/maximum-square-area-by-removing-fences-from-a-field) | ||
|
||
[English Version](/solution/2900-2999/2975.Maximum%20Square%20Area%20by%20Removing%20Fences%20From%20a%20Field/README_EN.md) | ||
|
||
## 题目描述 | ||
|
||
<!-- 这里写题目描述 --> | ||
|
||
<p>有一个大型的 <code>(m - 1) x (n - 1)</code> 矩形田地,其两个对角分别是 <code>(1, 1)</code> 和 <code>(m, n)</code> ,田地内部有一些水平栅栏和垂直栅栏,分别由数组 <code>hFences</code> 和 <code>vFences</code> 给出。</p> | ||
|
||
<p>水平栅栏为坐标 <code>(hFences[i], 1)</code> 到 <code>(hFences[i], n)</code>,垂直栅栏为坐标 <code>(1, vFences[i])</code> 到 <code>(m, vFences[i])</code> 。</p> | ||
|
||
<p>返回通过<strong> 移除 </strong>一些栅栏(<strong>可能不移除</strong>)所能形成的最大面积的<strong> 正方形 </strong>田地的面积,或者如果无法形成正方形田地则返回 <code>-1</code>。</p> | ||
|
||
<p>由于答案可能很大,所以请返回结果对 <code>10<sup>9</sup> + 7</code> <strong>取余</strong> 后的值。</p> | ||
|
||
<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> | ||
|
||
<p> </p> | ||
|
||
<p><strong class="example">示例 1:</strong></p> | ||
|
||
<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> | ||
|
||
<pre> | ||
<strong>输入:</strong>m = 4, n = 3, hFences = [2,3], vFences = [2] | ||
<strong>输出:</strong>4 | ||
<strong>解释:</strong>移除位于 2 的水平栅栏和位于 2 的垂直栅栏将得到一个面积为 4 的正方形田地。 | ||
</pre> | ||
|
||
<p><strong class="example">示例 2:</strong></p> | ||
|
||
<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> | ||
|
||
<pre> | ||
<strong>输入:</strong>m = 6, n = 7, hFences = [2], vFences = [4] | ||
<strong>输出:</strong>-1 | ||
<strong>解释:</strong>可以证明无法通过移除栅栏形成正方形田地。 | ||
</pre> | ||
|
||
<p> </p> | ||
|
||
<p><strong>提示:</strong></p> | ||
|
||
<ul> | ||
<li><code>3 <= m, n <= 10<sup>9</sup></code></li> | ||
<li><code>1 <= hFences.length, vFences.length <= 600</code></li> | ||
<li><code>1 < hFences[i] < m</code></li> | ||
<li><code>1 < vFences[i] < n</code></li> | ||
<li><code>hFences</code> 和 <code>vFences</code> 中的元素是唯一的。</li> | ||
</ul> | ||
|
||
## 解法 | ||
|
||
<!-- 这里可写通用的实现逻辑 --> | ||
|
||
<!-- tabs:start --> | ||
|
||
### **Python3** | ||
|
||
<!-- 这里可写当前语言的特殊实现逻辑 --> | ||
|
||
```python | ||
|
||
``` | ||
|
||
### **Java** | ||
|
||
<!-- 这里可写当前语言的特殊实现逻辑 --> | ||
|
||
```java | ||
|
||
``` | ||
|
||
### **C++** | ||
|
||
```cpp | ||
|
||
``` | ||
|
||
### **Go** | ||
|
||
```go | ||
|
||
``` | ||
|
||
### **...** | ||
|
||
``` | ||
``` | ||
|
||
<!-- tabs:end --> |
Oops, something went wrong.