#3395

Subsequences with a Unique Middle Mode I

grandmaster · 2205 · lc hard +32 · 21% accepted · 24 likes · top 2%

Description

Given an integer array nums, find the number of length-5 subsequences with a unique middle mode.

Since the answer may be very large, return it modulo 109 + 7.

A mode of a sequence is the element that appears most often.

A sequence has a unique mode if exactly one element achieves the maximum frequency.

A length-5 sequence seq has a unique middle mode if the middle element (seq[2]) is the unique mode.

Code

1
2
3