Get Stable Periods Count (Fungible :)
A team of financial analysts at Amazon closely monitors revenue generated by a newly launched product. They classify a period of one or more consecutive days as a stable-growth period if the revenue generated by the product takes no more than k distinct values over that period.
Given an array revenues of size n, that represents the revenues generated by the new product on n consecutive days, and an integer k, determine the total number of stable growth periods over the n days. Since the answer can be large, return it modulo (10^9 + 7).
Complete the function getStablePeriodsCount in the editor.
getStablePeriodsCount has the following parameters:
int revenues[n]: the revenues generated by the new product overndaysint k: the maximum number of distinct values in a stable growth period
Returns
int: the number of stable growth periods of the product over n days, modulo (10^9 + 7)
1Example 1

k=1 or fewer distinct values. The number of stable growth periods is 3.2Example 2
Constraints
Limits and guarantees your solution can rely on.
n β€ 10^5k β€ nrevenues[i] β€ 10^9