Get Stable Periods Count (Fungible :)
Problem Overview
- Count stable-growth periods (consecutive days) where revenue takes at most k distinct values.
- Input: array revenues of n days and integer k; Output: number of such periods modulo 1e9+7.
- Constraints: 1 ≤ n ≤ 1e5, 1 ≤ k ≤ n, revenues in [-1e9, 1e9].
- Real-world context: financial analysts tracking daily product revenue for stable growth.
- From Amazon interviews: a coding interview problem and interview question.
Example
Unlock to view complete problem details
and practice with sample input/output
Was this article helpful?
View Test Cases & Run Code requires membership
Input Variables
Execution Result:
