Problem 3639 · Medium

Minimum Time to Activate String

At each time t, the character at index order[t] becomes a star. Find the earliest t at which at least k substrings contain a star, or -1 if that never happens.

Open the interactive visualisation