diff --git a/solution/3000-3099/3019.Number of Changing Keys/README.md b/solution/3000-3099/3019.Number of Changing Keys/README.md index 065a79f073985..f4185f581cf1f 100644 --- a/solution/3000-3099/3019.Number of Changing Keys/README.md +++ b/solution/3000-3099/3019.Number of Changing Keys/README.md @@ -31,7 +31,7 @@ tags:
输入:s = "aAbBcC" 输出:2 -解释: +解释: 从 s[0] = 'a' 到 s[1] = 'A',不存在按键变更,因为不计入 caps lock 或 shift 。 从 s[1] = 'A' 到 s[2] = 'b',按键变更。 从 s[2] = 'b' 到 s[3] = 'B',不存在按键变更,因为不计入 caps lock 或 shift 。 diff --git a/solution/3000-3099/3019.Number of Changing Keys/README_EN.md b/solution/3000-3099/3019.Number of Changing Keys/README_EN.md index 40d4ccdb81352..dab3135859c5e 100644 --- a/solution/3000-3099/3019.Number of Changing Keys/README_EN.md +++ b/solution/3000-3099/3019.Number of Changing Keys/README_EN.md @@ -30,7 +30,7 @@ tags:Input: s = "aAbBcC" Output: 2 -Explanation: +Explanation: From s[0] = 'a' to s[1] = 'A', there is no change of key as caps lock or shift is not counted. From s[1] = 'A' to s[2] = 'b', there is a change of key. From s[2] = 'b' to s[3] = 'B', there is no change of key as caps lock or shift is not counted. diff --git a/solution/3400-3499/3416.Subsequences with a Unique Middle Mode II/README.md b/solution/3400-3499/3416.Subsequences with a Unique Middle Mode II/README.md new file mode 100644 index 0000000000000..401c3920d8ce7 --- /dev/null +++ b/solution/3400-3499/3416.Subsequences with a Unique Middle Mode II/README.md @@ -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 +--- + + + +# [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) + +## 题目描述 + + + +Given an integer array
+ +nums
, find the number of subsequences of size 5 ofnums
with a unique middle mode.Since the answer may be very large, return it modulo
+ +109 + 7
.A mode of a sequence of numbers is defined as the element that appears the maximum number of times in the sequence.
+ +A sequence of numbers contains a unique mode if it has only one mode.
+ +A sequence of numbers
+ +seq
of size 5 contains a unique middle mode if the middle element (seq[2]
) is a unique mode.+
Example 1:
+ +Input: nums = [1,1,1,1,1,1]
+ +Output: 6
+ +Explanation:
+ ++ +
[1, 1, 1, 1, 1]
is the only subsequence of size 5 that can be formed from this list, and it has a unique middle mode of 1.Example 2:
+ +Input: nums = [1,2,2,3,3,4]
+ +Output: 4
+ +Explanation:
+ ++ +
[1, 2, 2, 3, 4]
and[1, 2, 3, 3, 4]
have unique middle modes because the number at index 2 has the greatest frequency in the subsequence.[1, 2, 2, 3, 3]
does not have a unique middle mode because 2 and 3 both appear twice in the subsequence.Example 3:
+ +Input: nums = [0,1,2,3,4,5,6,7,8]
+ +Output: 0
+ +Explanation:
+ +There does not exist a subsequence of length 5 with a unique middle mode.
+ ++
Constraints:
+ +
5 <= nums.length <= 105
-109 <= nums[i] <= 109
Given an integer array nums
, find the number of subsequences of size 5 of nums
with a unique middle mode.
Since the answer may be very large, return it modulo 109 + 7
.
A mode of a sequence of numbers is defined as the element that appears the maximum number of times in the sequence.
+ +A sequence of numbers contains a unique mode if it has only one mode.
+ +A sequence of numbers seq
of size 5 contains a unique middle mode if the middle element (seq[2]
) is a unique mode.
+
Example 1:
+ +Input: nums = [1,1,1,1,1,1]
+ +Output: 6
+ +Explanation:
+ +[1, 1, 1, 1, 1]
is the only subsequence of size 5 that can be formed from this list, and it has a unique middle mode of 1.
Example 2:
+ +Input: nums = [1,2,2,3,3,4]
+ +Output: 4
+ +Explanation:
+ +[1, 2, 2, 3, 4]
and [1, 2, 3, 3, 4]
have unique middle modes because the number at index 2 has the greatest frequency in the subsequence. [1, 2, 2, 3, 3]
does not have a unique middle mode because 2 and 3 both appear twice in the subsequence.
Example 3:
+ +Input: nums = [0,1,2,3,4,5,6,7,8]
+ +Output: 0
+ +Explanation:
+ +There does not exist a subsequence of length 5 with a unique middle mode.
+ ++
Constraints:
+ +5 <= nums.length <= 105
-109 <= nums[i] <= 109