Skip to content

Commit 0fe974d

Browse files
committed
feat: add new lc problems
1 parent 7187d92 commit 0fe974d

File tree

23 files changed

+1192
-2
lines changed

23 files changed

+1192
-2
lines changed

solution/1300-1399/1323.Maximum 69 Number/README_EN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ tags:
2929
<pre>
3030
<strong>Input:</strong> num = 9669
3131
<strong>Output:</strong> 9969
32-
<strong>Explanation:</strong>
32+
<strong>Explanation:</strong>
3333
Changing the first digit results in 6669.
3434
Changing the second digit results in 9969.
3535
Changing the third digit results in 9699.

solution/3600-3699/3643.Flip Square Submatrix Vertically/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
comments: true
33
difficulty: 简单
44
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3600-3699/3643.Flip%20Square%20Submatrix%20Vertically/README.md
5+
rating: 1234
6+
source: 第 462 场周赛 Q1
57
---
68

79
<!-- problem:start -->

solution/3600-3699/3643.Flip Square Submatrix Vertically/README_EN.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
comments: true
33
difficulty: Easy
44
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3600-3699/3643.Flip%20Square%20Submatrix%20Vertically/README_EN.md
5+
rating: 1234
6+
source: Weekly Contest 462 Q1
57
---
68

79
<!-- problem:start -->

solution/3600-3699/3644.Maximum K to Sort a Permutation/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
comments: true
33
difficulty: 中等
44
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3600-3699/3644.Maximum%20K%20to%20Sort%20a%20Permutation/README.md
5+
rating: 1775
6+
source: 第 462 场周赛 Q2
57
---
68

79
<!-- problem:start -->

solution/3600-3699/3644.Maximum K to Sort a Permutation/README_EN.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
comments: true
33
difficulty: Medium
44
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3600-3699/3644.Maximum%20K%20to%20Sort%20a%20Permutation/README_EN.md
5+
rating: 1775
6+
source: Weekly Contest 462 Q2
57
---
68

79
<!-- problem:start -->

solution/3600-3699/3645.Maximum Total from Optimal Activation Order/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
comments: true
33
difficulty: 中等
44
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3600-3699/3645.Maximum%20Total%20from%20Optimal%20Activation%20Order/README.md
5+
rating: 2018
6+
source: 第 462 场周赛 Q3
57
---
68

79
<!-- problem:start -->

solution/3600-3699/3645.Maximum Total from Optimal Activation Order/README_EN.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
comments: true
33
difficulty: Medium
44
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3600-3699/3645.Maximum%20Total%20from%20Optimal%20Activation%20Order/README_EN.md
5+
rating: 2018
6+
source: Weekly Contest 462 Q3
57
---
68

79
<!-- problem:start -->

solution/3600-3699/3646.Next Special Palindrome Number/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
comments: true
33
difficulty: 困难
44
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3600-3699/3646.Next%20Special%20Palindrome%20Number/README.md
5+
rating: 2445
6+
source: 第 462 场周赛 Q4
57
---
68

79
<!-- problem:start -->

solution/3600-3699/3646.Next Special Palindrome Number/README_EN.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
comments: true
33
difficulty: Hard
44
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3600-3699/3646.Next%20Special%20Palindrome%20Number/README_EN.md
5+
rating: 2445
6+
source: Weekly Contest 462 Q4
57
---
68

79
<!-- problem:start -->
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
---
2+
comments: true
3+
difficulty: 中等
4+
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3600-3699/3648.Minimum%20Sensors%20to%20Cover%20Grid/README.md
5+
---
6+
7+
<!-- problem:start -->
8+
9+
# [3648. 覆盖网格的最少传感器数目](https://leetcode.cn/problems/minimum-sensors-to-cover-grid)
10+
11+
[English Version](/solution/3600-3699/3648.Minimum%20Sensors%20to%20Cover%20Grid/README_EN.md)
12+
13+
## 题目描述
14+
15+
<!-- description:start -->
16+
17+
<p>给你一个 <code>n × m</code> 的网格和一个整数 <code>k</code>。</p>
18+
19+
<p>一个放置在单元格 <code>(r, c)</code> 的传感器可以覆盖所有与 <code>(r, c)</code> 的&nbsp;<strong>切比雪夫距离</strong><strong>不超过</strong> <code>k</code> 的单元格。</p>
20+
21+
<p>两个单元格 <code>(r<sub>1</sub>, c<sub>1</sub>)</code> 和 <code>(r<sub>2</sub>, c<sub>2</sub>)</code> 之间的&nbsp;<strong>切比雪夫距离&nbsp;</strong>为 <code>max(|r<sub>1</sub> − r<sub>2</sub>|,|c<sub>1</sub> − c<sub>2</sub>|)</code>。</p>
22+
23+
<p>你的任务是返回覆盖整个网格所需传感器的&nbsp;<strong>最少&nbsp;</strong>数量。</p>
24+
25+
<p>&nbsp;</p>
26+
27+
<p><strong class="example">示例 1:</strong></p>
28+
29+
<div class="example-block">
30+
<p><strong>输入:</strong> <span class="example-io">n = 5, m = 5, k = 1</span></p>
31+
32+
<p><strong>输出:</strong> <span class="example-io">4</span></p>
33+
34+
<p><strong>解释:</strong></p>
35+
36+
<p>在位置 <code>(0, 3)</code>、<code>(1, 0)</code>、<code>(3, 3)</code> 和 <code>(4, 1)</code> 放置传感器可以确保网格中的每个单元格都被覆盖。因此,答案是 4。</p>
37+
</div>
38+
39+
<p><strong class="example">示例 2:</strong></p>
40+
41+
<div class="example-block">
42+
<p><strong>输入:</strong> <span class="example-io">n = 2, m = 2, k = 2</span></p>
43+
44+
<p><strong>输出:</strong> <span class="example-io">1</span></p>
45+
46+
<p><strong>解释:</strong></p>
47+
48+
<p>当 <code>k = 2</code> 时,无论传感器放在哪个位置,单个传感器都可以覆盖整个 <code>2 * 2</code> 的网格。因此,答案是 1。</p>
49+
</div>
50+
51+
<p>&nbsp;</p>
52+
53+
<p><strong>提示:</strong></p>
54+
55+
<ul>
56+
<li><code>1 &lt;= n &lt;= 10<sup>3</sup></code></li>
57+
<li><code>1 &lt;= m &lt;= 10<sup>3</sup></code></li>
58+
<li><code>0 &lt;= k &lt;= 10<sup>3</sup></code></li>
59+
</ul>
60+
61+
<!-- description:end -->
62+
63+
## 解法
64+
65+
<!-- solution:start -->
66+
67+
### 方法一
68+
69+
<!-- tabs:start -->
70+
71+
#### Python3
72+
73+
```python
74+
75+
```
76+
77+
#### Java
78+
79+
```java
80+
81+
```
82+
83+
#### C++
84+
85+
```cpp
86+
87+
```
88+
89+
#### Go
90+
91+
```go
92+
93+
```
94+
95+
<!-- tabs:end -->
96+
97+
<!-- solution:end -->
98+
99+
<!-- problem:end -->

0 commit comments

Comments
 (0)