Skip to content

feat: add new lc problems #4650

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion solution/1300-1399/1323.Maximum 69 Number/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ tags:
<pre>
<strong>Input:</strong> num = 9669
<strong>Output:</strong> 9969
<strong>Explanation:</strong>
<strong>Explanation:</strong>
Changing the first digit results in 6669.
Changing the second digit results in 9969.
Changing the third digit results in 9699.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
comments: true
difficulty: 简单
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3600-3699/3643.Flip%20Square%20Submatrix%20Vertically/README.md
rating: 1234
source: 第 462 场周赛 Q1
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
comments: true
difficulty: Easy
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3600-3699/3643.Flip%20Square%20Submatrix%20Vertically/README_EN.md
rating: 1234
source: Weekly Contest 462 Q1
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
comments: true
difficulty: 中等
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3600-3699/3644.Maximum%20K%20to%20Sort%20a%20Permutation/README.md
rating: 1775
source: 第 462 场周赛 Q2
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
comments: true
difficulty: Medium
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3600-3699/3644.Maximum%20K%20to%20Sort%20a%20Permutation/README_EN.md
rating: 1775
source: Weekly Contest 462 Q2
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
comments: true
difficulty: 中等
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3600-3699/3645.Maximum%20Total%20from%20Optimal%20Activation%20Order/README.md
rating: 2018
source: 第 462 场周赛 Q3
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
comments: true
difficulty: Medium
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3600-3699/3645.Maximum%20Total%20from%20Optimal%20Activation%20Order/README_EN.md
rating: 2018
source: Weekly Contest 462 Q3
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
comments: true
difficulty: 困难
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3600-3699/3646.Next%20Special%20Palindrome%20Number/README.md
rating: 2445
source: 第 462 场周赛 Q4
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
comments: true
difficulty: Hard
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3600-3699/3646.Next%20Special%20Palindrome%20Number/README_EN.md
rating: 2445
source: Weekly Contest 462 Q4
---

<!-- problem:start -->
Expand Down
99 changes: 99 additions & 0 deletions solution/3600-3699/3648.Minimum Sensors to Cover Grid/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
---
comments: true
difficulty: 中等
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3600-3699/3648.Minimum%20Sensors%20to%20Cover%20Grid/README.md
---

<!-- problem:start -->

# [3648. 覆盖网格的最少传感器数目](https://leetcode.cn/problems/minimum-sensors-to-cover-grid)

[English Version](/solution/3600-3699/3648.Minimum%20Sensors%20to%20Cover%20Grid/README_EN.md)

## 题目描述

<!-- description:start -->

<p>给你一个 <code>n × m</code> 的网格和一个整数 <code>k</code>。</p>

<p>一个放置在单元格 <code>(r, c)</code> 的传感器可以覆盖所有与 <code>(r, c)</code> 的&nbsp;<strong>切比雪夫距离</strong><strong>不超过</strong> <code>k</code> 的单元格。</p>

<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>

<p>你的任务是返回覆盖整个网格所需传感器的&nbsp;<strong>最少&nbsp;</strong>数量。</p>

<p>&nbsp;</p>

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

<div class="example-block">
<p><strong>输入:</strong> <span class="example-io">n = 5, m = 5, k = 1</span></p>

<p><strong>输出:</strong> <span class="example-io">4</span></p>

<p><strong>解释:</strong></p>

<p>在位置 <code>(0, 3)</code>、<code>(1, 0)</code>、<code>(3, 3)</code> 和 <code>(4, 1)</code> 放置传感器可以确保网格中的每个单元格都被覆盖。因此,答案是 4。</p>
</div>

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

<div class="example-block">
<p><strong>输入:</strong> <span class="example-io">n = 2, m = 2, k = 2</span></p>

<p><strong>输出:</strong> <span class="example-io">1</span></p>

<p><strong>解释:</strong></p>

<p>当 <code>k = 2</code> 时,无论传感器放在哪个位置,单个传感器都可以覆盖整个 <code>2 * 2</code> 的网格。因此,答案是 1。</p>
</div>

<p>&nbsp;</p>

<p><strong>提示:</strong></p>

<ul>
<li><code>1 &lt;= n &lt;= 10<sup>3</sup></code></li>
<li><code>1 &lt;= m &lt;= 10<sup>3</sup></code></li>
<li><code>0 &lt;= k &lt;= 10<sup>3</sup></code></li>
</ul>

<!-- description:end -->

## 解法

<!-- solution:start -->

### 方法一

<!-- tabs:start -->

#### Python3

```python

```

#### Java

```java

```

#### C++

```cpp

```

#### Go

```go

```

<!-- tabs:end -->

<!-- solution:end -->

<!-- problem:end -->
97 changes: 97 additions & 0 deletions solution/3600-3699/3648.Minimum Sensors to Cover Grid/README_EN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
---
comments: true
difficulty: Medium
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3600-3699/3648.Minimum%20Sensors%20to%20Cover%20Grid/README_EN.md
---

<!-- problem:start -->

# [3648. Minimum Sensors to Cover Grid](https://leetcode.com/problems/minimum-sensors-to-cover-grid)

[中文文档](/solution/3600-3699/3648.Minimum%20Sensors%20to%20Cover%20Grid/README.md)

## Description

<!-- description:start -->

<p>You are given <code>n &times; m</code> grid and an integer <code>k</code>.</p>

<p>A sensor placed on cell <code>(r, c)</code> covers all cells whose <strong>Chebyshev distance</strong> from <code>(r, c)</code> is <strong>at most</strong> <code>k</code>.</p>

<p>The <strong>Chebyshev distance</strong> between two cells <code>(r<sub>1</sub>, c<sub>1</sub>)</code> and <code>(r<sub>2</sub>, c<sub>2</sub>)</code> is <code>max(|r<sub>1</sub> &minus; r<sub>2</sub>|,|c<sub>1</sub> &minus; c<sub>2</sub>|)</code>.</p>

<p>Your task is to return the <strong>minimum</strong> number of sensors required to cover every cell of the grid.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">n = 5, m = 5, k = 1</span></p>

<p><strong>Output:</strong> <span class="example-io">4</span></p>

<p><strong>Explanation:</strong></p>

<p>Placing sensors at positions <code>(0, 3)</code>, <code>(1, 0)</code>, <code>(3, 3)</code>, and <code>(4, 1)</code> ensures every cell in the grid is covered. Thus, the answer is 4.</p>
</div>

<p><strong class="example">Example 2:</strong></p>

<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">n = 2, m = 2, k = 2</span></p>

<p><strong>Output:</strong> <span class="example-io">1</span></p>

<p><strong>Explanation:</strong></p>

<p>With <code>k = 2</code>, a single sensor can cover the entire <code>2 * 2</code> grid regardless of its position. Thus, the answer is 1.</p>
</div>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
<li><code>1 &lt;= n &lt;= 10<sup>3</sup></code></li>
<li><code>1 &lt;= m &lt;= 10<sup>3</sup></code></li>
<li><code>0 &lt;= k &lt;= 10<sup>3</sup></code></li>
</ul>

<!-- description:end -->

## Solutions

<!-- solution:start -->

### Solution 1

<!-- tabs:start -->

#### Python3

```python

```

#### Java

```java

```

#### C++

```cpp

```

#### Go

```go

```

<!-- tabs:end -->

<!-- solution:end -->

<!-- problem:end -->
Loading
Loading