Problem 3940 · Easy

Limit Occurrences in Sorted Array

Walk the sorted array once and keep a value only while it has been kept fewer than k times.

Open the interactive visualisation