Skip to content

Practice Subsequences with a Unique Middle Mode I

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Hard#3395
LeetCode Problem

Subsequences with a Unique Middle Mode I

Problem Statement

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 10^9 + 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.

Source: Subsequences with a Unique Middle Mode I on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
nums = [1,1,1,1,1,1]
Output
6

# Example 2

Input
nums = [1,2,2,3,3,4]
Output
4

# Example 3

Input
nums = [0,1,2,3,4,5,6,7,8]
Output
0

Constraints

5 <= nums.length <= 1000
-10^9 <= nums[i] <= 10^9

Related LeetCode Problems

Practice more problems similar to Subsequences with a Unique Middle Mode I.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.