Problem 2904 · Medium

Shortest and Lexicographically Smallest Beautiful String

Slide a window over a binary string that holds exactly k ones, keeping the shortest and then smallest candidate.

Open the interactive visualisation