Skip to content

feat: add new lc problems #4453

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
Jun 2, 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
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
---
comments: true
difficulty: 简单
edit_url: https://github.com/doocs/leetcode/edit/main/solution/0500-0599/0596.Classes%20More%20Than%205%20Students/README.md
edit_url: https://github.com/doocs/leetcode/edit/main/solution/0500-0599/0596.Classes%20With%20at%20Least%205%20Students/README.md
tags:
- 数据库
---

<!-- problem:start -->

# [596. 超过 5 名学生的课](https://leetcode.cn/problems/classes-more-than-5-students)
# [596. 超过 5 名学生的课](https://leetcode.cn/problems/classes-with-at-least-5-students)

[English Version](/solution/0500-0599/0596.Classes%20More%20Than%205%20Students/README_EN.md)
[English Version](/solution/0500-0599/0596.Classes%20With%20at%20Least%205%20Students/README_EN.md)

## 题目描述

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
---
comments: true
difficulty: Easy
edit_url: https://github.com/doocs/leetcode/edit/main/solution/0500-0599/0596.Classes%20More%20Than%205%20Students/README_EN.md
edit_url: https://github.com/doocs/leetcode/edit/main/solution/0500-0599/0596.Classes%20With%20at%20Least%205%20Students/README_EN.md
tags:
- Database
---

<!-- problem:start -->

# [596. Classes More Than 5 Students](https://leetcode.com/problems/classes-more-than-5-students)
# [596. Classes With at Least 5 Students](https://leetcode.com/problems/classes-with-at-least-5-students)

[中文文档](/solution/0500-0599/0596.Classes%20More%20Than%205%20Students/README.md)
[中文文档](/solution/0500-0599/0596.Classes%20With%20at%20Least%205%20Students/README.md)

## Description

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
---
comments: true
difficulty: 中等
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3500-3599/3566.Partition%20Array%20into%20Two%20Equal%20Product%20Subsets/README.md
---

<!-- problem:start -->

# [3566. 等积子集的划分方案](https://leetcode.cn/problems/partition-array-into-two-equal-product-subsets)

[English Version](/solution/3500-3599/3566.Partition%20Array%20into%20Two%20Equal%20Product%20Subsets/README_EN.md)

## 题目描述

<!-- description:start -->

<p>给你一个整数数组 <code>nums</code>,其中包含的正整数&nbsp;<strong>互不相同&nbsp;</strong>,另给你一个整数 <code>target</code>。</p>

<p>请判断是否可以将 <code>nums</code> 分成两个&nbsp;<strong>非空</strong>、<strong>互不相交&nbsp;</strong>的&nbsp;<strong>子集&nbsp;</strong>,并且每个元素必须 &nbsp;<strong>恰好 </strong>属于&nbsp;<strong>一个&nbsp;</strong>子集,使得这两个子集中元素的乘积都等于 <code>target</code>。</p>

<p>如果存在这样的划分,返回 <code>true</code>;否则,返回 <code>false</code>。</p>

<p><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">nums = [3,1,6,8,4], target = 24</span></p>

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

<p><strong>解释:</strong>子集 <code>[3, 8]</code> 和 <code>[1, 6, 4]</code> 的乘积均为 24。因此,输出为 true 。</p>
</div>

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

<div class="example-block">
<p><strong>输入:</strong> <span class="example-io">nums = [2,5,3,7], target = 15</span></p>

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

<p><strong>解释:</strong>无法将 <code>nums</code> 划分为两个非空的互不相交子集,使得它们的乘积均为 15。因此,输出为 false。</p>
</div>

<p>&nbsp;</p>

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

<ul>
<li><code>3 &lt;= nums.length &lt;= 12</code></li>
<li><code>1 &lt;= target &lt;= 10<sup>15</sup></code></li>
<li><code>1 &lt;= nums[i] &lt;= 100</code></li>
<li><code>nums</code> 中的所有元素互不相同。</li>
</ul>

<!-- description:end -->

## 解法

<!-- solution:start -->

### 方法一

<!-- tabs:start -->

#### Python3

```python

```

#### Java

```java

```

#### C++

```cpp

```

#### Go

```go

```

<!-- tabs:end -->

<!-- solution:end -->

<!-- problem:end -->
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
---
comments: true
difficulty: Medium
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3500-3599/3566.Partition%20Array%20into%20Two%20Equal%20Product%20Subsets/README_EN.md
---

<!-- problem:start -->

# [3566. Partition Array into Two Equal Product Subsets](https://leetcode.com/problems/partition-array-into-two-equal-product-subsets)

[中文文档](/solution/3500-3599/3566.Partition%20Array%20into%20Two%20Equal%20Product%20Subsets/README.md)

## Description

<!-- description:start -->

<p>You are given an integer array <code>nums</code> containing <strong>distinct</strong> positive integers and an integer <code>target</code>.</p>

<p>Determine if you can partition <code>nums</code> into two <strong>non-empty</strong> <strong>disjoint</strong> <strong>subsets</strong>, with each element belonging to <strong>exactly one</strong> subset, such that the product of the elements in each subset is equal to <code>target</code>.</p>

<p>Return <code>true</code> if such a partition exists and <code>false</code> otherwise.</p>
A <strong>subset</strong> of an array is a selection of elements of the array.
<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">nums = [3,1,6,8,4], target = 24</span></p>

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

<p><strong>Explanation:</strong> The subsets <code>[3, 8]</code> and <code>[1, 6, 4]</code> each have a product of 24. Hence, the output is true.</p>
</div>

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

<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">nums = [2,5,3,7], target = 15</span></p>

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

<p><strong>Explanation:</strong> There is no way to partition <code>nums</code> into two non-empty disjoint subsets such that both subsets have a product of 15. Hence, the output is false.</p>
</div>

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

<ul>
<li><code>3 &lt;= nums.length &lt;= 12</code></li>
<li><code>1 &lt;= target &lt;= 10<sup>15</sup></code></li>
<li><code>1 &lt;= nums[i] &lt;= 100</code></li>
<li>All elements of <code>nums</code> are <strong>distinct</strong>.</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 -->
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
---
comments: true
difficulty: 中等
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3500-3599/3567.Minimum%20Absolute%20Difference%20in%20Sliding%20Submatrix/README.md
---

<!-- problem:start -->

# [3567. 子矩阵的最小绝对差](https://leetcode.cn/problems/minimum-absolute-difference-in-sliding-submatrix)

[English Version](/solution/3500-3599/3567.Minimum%20Absolute%20Difference%20in%20Sliding%20Submatrix/README_EN.md)

## 题目描述

<!-- description:start -->

<p>给你一个 <code>m x n</code> 的整数矩阵 <code>grid</code> 和一个整数 <code>k</code>。</p>

<p>对于矩阵 <code>grid</code> 中的每个连续的 <code>k x k</code> <strong>子矩阵</strong>,计算其中任意两个&nbsp;<strong>不同</strong>值 之间的&nbsp;<strong>最小绝对差&nbsp;</strong>。</p>

<p>返回一个大小为 <code>(m - k + 1) x (n - k + 1)</code> 的二维数组 <code>ans</code>,其中 <code>ans[i][j]</code> 表示以 <code>grid</code> 中坐标 <code>(i, j)</code> 为左上角的子矩阵的最小绝对差。</p>

<p><strong>注意</strong>:如果子矩阵中的所有元素都相同,则答案为 0。</p>

<p>子矩阵 <code>(x1, y1, x2, y2)</code> 是一个由选择矩阵中所有满足 <code>x1 &lt;= x &lt;= x2</code> 且 <code>y1 &lt;= y &lt;= y2</code> 的单元格 <code>matrix[x][y]</code> 组成的矩阵。</p>

<p>&nbsp;</p>

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

<div class="example-block">
<p><strong>输入:</strong> <span class="example-io">grid = [[1,8],[3,-2]], k = 2</span></p>

<p><strong>输出:</strong> <span class="example-io">[[2]]</span></p>

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

<ul>
<li>只有一个可能的 <code>k x k</code> 子矩阵:<code><span class="example-io">[[1, 8], [3, -2]]</span></code>。</li>
<li>子矩阵中的不同值为 <code>[1, 8, 3, -2]</code>。</li>
<li>子矩阵中的最小绝对差为 <code>|1 - 3| = 2</code>。因此,答案为 <code>[[2]]</code>。</li>
</ul>
</div>

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

<div class="example-block">
<p><strong>输入:</strong> <span class="example-io">grid = [[3,-1]], k = 1</span></p>

<p><strong>输出:</strong> <span class="example-io">[[0,0]]</span></p>

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

<ul>
<li>每个 <code>k x k</code> 子矩阵中只有一个不同的元素。</li>
<li>因此,答案为 <code>[[0, 0]]</code>。</li>
</ul>
</div>

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

<div class="example-block">
<p><strong>输入:</strong> <span class="example-io">grid = [[1,-2,3],[2,3,5]], k = 2</span></p>

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

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

<ul>
<li>有两个可能的 <code>k × k</code> 子矩阵:

<ul>
<li>以 <code>(0, 0)</code> 为起点的子矩阵:<code>[[1, -2], [2, 3]]</code>。

<ul>
<li>子矩阵中的不同值为 <code>[1, -2, 2, 3]</code>。</li>
<li>子矩阵中的最小绝对差为 <code>|1 - 2| = 1</code>。</li>
</ul>
</li>
<li>以 <code>(0, 1)</code> 为起点的子矩阵:<code>[[-2, 3], [3, 5]]</code>。
<ul>
<li>子矩阵中的不同值为 <code>[-2, 3, 5]</code>。</li>
<li>子矩阵中的最小绝对差为 <code>|3 - 5| = 2</code>。</li>
</ul>
</li>
</ul>
</li>
<li>因此,答案为 <code>[[1, 2]]</code>。</li>

</ul>
</div>

<p>&nbsp;</p>

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

<ul>
<li><code>1 &lt;= m == grid.length &lt;= 30</code></li>
<li><code>1 &lt;= n == grid[i].length &lt;= 30</code></li>
<li><code>-10<sup>5</sup> &lt;= grid[i][j] &lt;= 10<sup>5</sup></code></li>
<li><code>1 &lt;= k &lt;= min(m, n)</code></li>
</ul>

<!-- description:end -->

## 解法

<!-- solution:start -->

### 方法一

<!-- tabs:start -->

#### Python3

```python

```

#### Java

```java

```

#### C++

```cpp

```

#### Go

```go

```

<!-- tabs:end -->

<!-- solution:end -->

<!-- problem:end -->
Loading