Problem 4032 · Medium

Longest Subarray With at Most K Distinct Prime Factors

Slide a window over the array and track how many windows primes are present, shrinking whenever more than k distinct primes appear.

Open the interactive visualisation