Skip to content

feat: update lc problems #3941

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 1 commit into from
Jan 10, 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/3000-3099/3019.Number of Changing Keys/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ tags:
<pre>
<strong>输入:</strong>s = "aAbBcC"
<strong>输出:</strong>2
<strong>解释:</strong>
<strong>解释:</strong>
从 s[0] = 'a' 到 s[1] = 'A',不存在按键变更,因为不计入 caps lock 或 shift 。
从 s[1] = 'A' 到 s[2] = 'b',按键变更。
从 s[2] = 'b' 到 s[3] = 'B',不存在按键变更,因为不计入 caps lock 或 shift 。
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ tags:
<pre>
<strong>Input:</strong> s = &quot;aAbBcC&quot;
<strong>Output:</strong> 2
<strong>Explanation:</strong>
<strong>Explanation:</strong>
From s[0] = &#39;a&#39; to s[1] = &#39;A&#39;, there is no change of key as caps lock or shift is not counted.
From s[1] = &#39;A&#39; to s[2] = &#39;b&#39;, there is a change of key.
From s[2] = &#39;b&#39; to s[3] = &#39;B&#39;, there is no change of key as caps lock or shift is not counted.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
---
comments: true
difficulty: 困难
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3400-3499/3416.Subsequences%20with%20a%20Unique%20Middle%20Mode%20II/README.md
---

<!-- problem:start -->

# [3416. Subsequences with a Unique Middle Mode II 🔒](https://leetcode.cn/problems/subsequences-with-a-unique-middle-mode-ii)

[English Version](/solution/3400-3499/3416.Subsequences%20with%20a%20Unique%20Middle%20Mode%20II/README_EN.md)

## 题目描述

<!-- description:start -->

<p>Given an integer array <code>nums</code>, find the number of <span data-keyword="subsequence-array">subsequences</span> of size 5 of&nbsp;<code>nums</code> with a <strong>unique middle mode</strong>.</p>

<p>Since the answer may be very large, return it <strong>modulo</strong> <code>10<sup>9</sup> + 7</code>.</p>

<p>A <strong>mode</strong> of a sequence of numbers is defined as the element that appears the <strong>maximum</strong> number of times in the sequence.</p>

<p>A sequence of numbers contains a<strong> unique mode</strong> if it has only one mode.</p>

<p>A sequence of numbers <code>seq</code> of size 5 contains a <strong>unique middle mode</strong> if the <em>middle element</em> (<code>seq[2]</code>) is a <strong>unique mode</strong>.</p>

<p>&nbsp;</p>
<p><strong>Example 1:</strong></p>

<p><strong>Input:</strong> nums = [1,1,1,1,1,1]</p>

<p><strong>Output:</strong> 6</p>

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

<p><code>[1, 1, 1, 1, 1]</code> is the only subsequence of size 5 that can be formed from this list, and it has a unique middle mode of 1.</p>

<p><strong>Example 2:</strong></p>

<p><strong>Input:</strong> nums = [1,2,2,3,3,4]</p>

<p><strong>Output:</strong> 4</p>

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

<p><code>[1, 2, 2, 3, 4]</code> and <code>[1, 2, 3, 3, 4]</code> have unique middle modes because the number at index 2 has the greatest frequency in the subsequence. <code>[1, 2, 2, 3, 3]</code> does not have a unique middle mode because 2 and 3 both appear twice in the subsequence.</p>

<p><strong>Example 3:</strong></p>

<p><strong>Input:</strong> nums = [0,1,2,3,4,5,6,7,8]</p>

<p><strong>Output:</strong> 0</p>

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

<p>There does not exist a subsequence of length 5 with a unique middle mode.</p>

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

<ul>
<li><code>5 &lt;= nums.length &lt;= 10<sup>5</sup></code></li>
<li><code>-10<sup>9</sup> &lt;= nums[i] &lt;= 10<sup>9</sup></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,104 @@
---
comments: true
difficulty: Hard
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3400-3499/3416.Subsequences%20with%20a%20Unique%20Middle%20Mode%20II/README_EN.md
---

<!-- problem:start -->

# [3416. Subsequences with a Unique Middle Mode II 🔒](https://leetcode.com/problems/subsequences-with-a-unique-middle-mode-ii)

[中文文档](/solution/3400-3499/3416.Subsequences%20with%20a%20Unique%20Middle%20Mode%20II/README.md)

## Description

<!-- description:start -->

<p>Given an integer array <code>nums</code>, find the number of <span data-keyword="subsequence-array">subsequences</span> of size 5 of&nbsp;<code>nums</code> with a <strong>unique middle mode</strong>.</p>

<p>Since the answer may be very large, return it <strong>modulo</strong> <code>10<sup>9</sup> + 7</code>.</p>

<p>A <strong>mode</strong> of a sequence of numbers is defined as the element that appears the <strong>maximum</strong> number of times in the sequence.</p>

<p>A sequence of numbers contains a<strong> unique mode</strong> if it has only one mode.</p>

<p>A sequence of numbers <code>seq</code> of size 5 contains a <strong>unique middle mode</strong> if the <em>middle element</em> (<code>seq[2]</code>) is a <strong>unique mode</strong>.</p>

<p>&nbsp;</p>
<p><strong>Example 1:</strong></p>

<p><strong>Input:</strong> nums = [1,1,1,1,1,1]</p>

<p><strong>Output:</strong> 6</p>

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

<p><code>[1, 1, 1, 1, 1]</code> is the only subsequence of size 5 that can be formed from this list, and it has a unique middle mode of 1.</p>

<p><strong>Example 2:</strong></p>

<p><strong>Input:</strong> nums = [1,2,2,3,3,4]</p>

<p><strong>Output:</strong> 4</p>

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

<p><code>[1, 2, 2, 3, 4]</code> and <code>[1, 2, 3, 3, 4]</code> have unique middle modes because the number at index 2 has the greatest frequency in the subsequence. <code>[1, 2, 2, 3, 3]</code> does not have a unique middle mode because 2 and 3 both appear twice in the subsequence.</p>

<p><strong>Example 3:</strong></p>

<p><strong>Input:</strong> nums = [0,1,2,3,4,5,6,7,8]</p>

<p><strong>Output:</strong> 0</p>

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

<p>There does not exist a subsequence of length 5 with a unique middle mode.</p>

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

<ul>
<li><code>5 &lt;= nums.length &lt;= 10<sup>5</sup></code></li>
<li><code>-10<sup>9</sup> &lt;= nums[i] &lt;= 10<sup>9</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 -->
1 change: 1 addition & 0 deletions solution/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3426,6 +3426,7 @@
| 3413 | [收集连续 K 个袋子可以获得的最多硬币数量](/solution/3400-3499/3413.Maximum%20Coins%20From%20K%20Consecutive%20Bags/README.md) | | 中等 | 第 431 场周赛 |
| 3414 | [不重叠区间的最大得分](/solution/3400-3499/3414.Maximum%20Score%20of%20Non-overlapping%20Intervals/README.md) | | 困难 | 第 431 场周赛 |
| 3415 | [Find Products with Three Consecutive Digits](/solution/3400-3499/3415.Find%20Products%20with%20Three%20Consecutive%20Digits/README.md) | | 简单 | 🔒 |
| 3416 | [Subsequences with a Unique Middle Mode II](/solution/3400-3499/3416.Subsequences%20with%20a%20Unique%20Middle%20Mode%20II/README.md) | | 困难 | 🔒 |

## 版权

Expand Down
1 change: 1 addition & 0 deletions solution/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -3424,6 +3424,7 @@ Press <kbd>Control</kbd> + <kbd>F</kbd>(or <kbd>Command</kbd> + <kbd>F</kbd> on
| 3413 | [Maximum Coins From K Consecutive Bags](/solution/3400-3499/3413.Maximum%20Coins%20From%20K%20Consecutive%20Bags/README_EN.md) | | Medium | Weekly Contest 431 |
| 3414 | [Maximum Score of Non-overlapping Intervals](/solution/3400-3499/3414.Maximum%20Score%20of%20Non-overlapping%20Intervals/README_EN.md) | | Hard | Weekly Contest 431 |
| 3415 | [Find Products with Three Consecutive Digits](/solution/3400-3499/3415.Find%20Products%20with%20Three%20Consecutive%20Digits/README_EN.md) | | Easy | 🔒 |
| 3416 | [Subsequences with a Unique Middle Mode II](/solution/3400-3499/3416.Subsequences%20with%20a%20Unique%20Middle%20Mode%20II/README_EN.md) | | Hard | 🔒 |

## Copyright

Expand Down
Loading