Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit e27eeca

Browse files
feat: update lc problems (doocs#3941)
1 parent 576142f commit e27eeca

File tree

6 files changed

+212
-2
lines changed

6 files changed

+212
-2
lines changed

‎solution/3000-3099/3019.Number of Changing Keys/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ tags:
3131
<pre>
3232
<strong>输入:</strong>s = "aAbBcC"
3333
<strong>输出:</strong>2
34-
<strong>解释:</strong>
34+
<strong>解释:</strong>
3535
从 s[0] = 'a' 到 s[1] = 'A',不存在按键变更,因为不计入 caps lock 或 shift 。
3636
从 s[1] = 'A' 到 s[2] = 'b',按键变更。
3737
从 s[2] = 'b' 到 s[3] = 'B',不存在按键变更,因为不计入 caps lock 或 shift 。

‎solution/3000-3099/3019.Number of Changing Keys/README_EN.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ tags:
3030
<pre>
3131
<strong>Input:</strong> s = &quot;aAbBcC&quot;
3232
<strong>Output:</strong> 2
33-
<strong>Explanation:</strong>
33+
<strong>Explanation:</strong>
3434
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.
3535
From s[1] = &#39;A&#39; to s[2] = &#39;b&#39;, there is a change of key.
3636
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.
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
---
2+
comments: true
3+
difficulty: 困难
4+
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3400-3499/3416.Subsequences%20with%20a%20Unique%20Middle%20Mode%20II/README.md
5+
---
6+
7+
<!-- problem:start -->
8+
9+
# [3416. Subsequences with a Unique Middle Mode II 🔒](https://leetcode.cn/problems/subsequences-with-a-unique-middle-mode-ii)
10+
11+
[English Version](/solution/3400-3499/3416.Subsequences%20with%20a%20Unique%20Middle%20Mode%20II/README_EN.md)
12+
13+
## 题目描述
14+
15+
<!-- description:start -->
16+
17+
<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>
18+
19+
<p>Since the answer may be very large, return it <strong>modulo</strong> <code>10<sup>9</sup> + 7</code>.</p>
20+
21+
<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>
22+
23+
<p>A sequence of numbers contains a<strong> unique mode</strong> if it has only one mode.</p>
24+
25+
<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>
26+
27+
<p>&nbsp;</p>
28+
<p><strong>Example 1:</strong></p>
29+
30+
<p><strong>Input:</strong> nums = [1,1,1,1,1,1]</p>
31+
32+
<p><strong>Output:</strong> 6</p>
33+
34+
<p><strong>Explanation:</strong></p>
35+
36+
<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>
37+
38+
<p><strong>Example 2:</strong></p>
39+
40+
<p><strong>Input:</strong> nums = [1,2,2,3,3,4]</p>
41+
42+
<p><strong>Output:</strong> 4</p>
43+
44+
<p><strong>Explanation:</strong></p>
45+
46+
<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>
47+
48+
<p><strong>Example 3:</strong></p>
49+
50+
<p><strong>Input:</strong> nums = [0,1,2,3,4,5,6,7,8]</p>
51+
52+
<p><strong>Output:</strong> 0</p>
53+
54+
<p><strong>Explanation:</strong></p>
55+
56+
<p>There does not exist a subsequence of length 5 with a unique middle mode.</p>
57+
58+
<p>&nbsp;</p>
59+
<p><strong>Constraints:</strong></p>
60+
61+
<ul>
62+
<li><code>5 &lt;= nums.length &lt;= 10<sup>5</sup></code></li>
63+
<li><code>-10<sup>9</sup> &lt;= nums[i] &lt;= 10<sup>9</sup></code></li>
64+
</ul>
65+
66+
<!-- description:end -->
67+
68+
## 解法
69+
70+
<!-- solution:start -->
71+
72+
### 方法一
73+
74+
<!-- tabs:start -->
75+
76+
#### Python3
77+
78+
```python
79+
80+
```
81+
82+
#### Java
83+
84+
```java
85+
86+
```
87+
88+
#### C++
89+
90+
```cpp
91+
92+
```
93+
94+
#### Go
95+
96+
```go
97+
98+
```
99+
100+
<!-- tabs:end -->
101+
102+
<!-- solution:end -->
103+
104+
<!-- problem:end -->
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
---
2+
comments: true
3+
difficulty: Hard
4+
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3400-3499/3416.Subsequences%20with%20a%20Unique%20Middle%20Mode%20II/README_EN.md
5+
---
6+
7+
<!-- problem:start -->
8+
9+
# [3416. Subsequences with a Unique Middle Mode II 🔒](https://leetcode.com/problems/subsequences-with-a-unique-middle-mode-ii)
10+
11+
[中文文档](/solution/3400-3499/3416.Subsequences%20with%20a%20Unique%20Middle%20Mode%20II/README.md)
12+
13+
## Description
14+
15+
<!-- description:start -->
16+
17+
<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>
18+
19+
<p>Since the answer may be very large, return it <strong>modulo</strong> <code>10<sup>9</sup> + 7</code>.</p>
20+
21+
<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>
22+
23+
<p>A sequence of numbers contains a<strong> unique mode</strong> if it has only one mode.</p>
24+
25+
<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>
26+
27+
<p>&nbsp;</p>
28+
<p><strong>Example 1:</strong></p>
29+
30+
<p><strong>Input:</strong> nums = [1,1,1,1,1,1]</p>
31+
32+
<p><strong>Output:</strong> 6</p>
33+
34+
<p><strong>Explanation:</strong></p>
35+
36+
<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>
37+
38+
<p><strong>Example 2:</strong></p>
39+
40+
<p><strong>Input:</strong> nums = [1,2,2,3,3,4]</p>
41+
42+
<p><strong>Output:</strong> 4</p>
43+
44+
<p><strong>Explanation:</strong></p>
45+
46+
<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>
47+
48+
<p><strong>Example 3:</strong></p>
49+
50+
<p><strong>Input:</strong> nums = [0,1,2,3,4,5,6,7,8]</p>
51+
52+
<p><strong>Output:</strong> 0</p>
53+
54+
<p><strong>Explanation:</strong></p>
55+
56+
<p>There does not exist a subsequence of length 5 with a unique middle mode.</p>
57+
58+
<p>&nbsp;</p>
59+
<p><strong>Constraints:</strong></p>
60+
61+
<ul>
62+
<li><code>5 &lt;= nums.length &lt;= 10<sup>5</sup></code></li>
63+
<li><code>-10<sup>9</sup> &lt;= nums[i] &lt;= 10<sup>9</sup></code></li>
64+
</ul>
65+
66+
<!-- description:end -->
67+
68+
## Solutions
69+
70+
<!-- solution:start -->
71+
72+
### Solution 1
73+
74+
<!-- tabs:start -->
75+
76+
#### Python3
77+
78+
```python
79+
80+
```
81+
82+
#### Java
83+
84+
```java
85+
86+
```
87+
88+
#### C++
89+
90+
```cpp
91+
92+
```
93+
94+
#### Go
95+
96+
```go
97+
98+
```
99+
100+
<!-- tabs:end -->
101+
102+
<!-- solution:end -->
103+
104+
<!-- problem:end -->

‎solution/README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3426,6 +3426,7 @@
34263426
| 3413 | [收集连续 K 个袋子可以获得的最多硬币数量](/solution/3400-3499/3413.Maximum%20Coins%20From%20K%20Consecutive%20Bags/README.md) | | 中等 | 第 431 场周赛 |
34273427
| 3414 | [不重叠区间的最大得分](/solution/3400-3499/3414.Maximum%20Score%20of%20Non-overlapping%20Intervals/README.md) | | 困难 | 第 431 场周赛 |
34283428
| 3415 | [Find Products with Three Consecutive Digits](/solution/3400-3499/3415.Find%20Products%20with%20Three%20Consecutive%20Digits/README.md) | | 简单 | 🔒 |
3429+
| 3416 | [Subsequences with a Unique Middle Mode II](/solution/3400-3499/3416.Subsequences%20with%20a%20Unique%20Middle%20Mode%20II/README.md) | | 困难 | 🔒 |
34293430

34303431
## 版权
34313432

‎solution/README_EN.md‎

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

34283429
## Copyright
34293430

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /