Problem 3940 · Easy
Walk the sorted array once and keep a value only while it has been kept fewer than k times.
Open the interactive visualisation