Problem 2962 · Medium

Count Subarrays Where Max Element Appears at Least K Times

Slide a window that counts occurrences of the maximum and add every start that still holds at least k of them.

Open the interactive visualisation