Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Counter solution in Clear category for When "k" is Enough! by juestr
from collections import Counter
from typing import Iterable
def remove_after_kth(items: list, k: int) -> Iterable:
c = Counter()
for i in items:
if c[i] < k:
c.update((i,))
yield i
Oct. 21, 2022