Search
⌘K

Leetcode 2904. Shortest and Lexicographically Smallest Beautiful String

Given a binary string s and integer k, find the shortest substring that contains exactly k '1's and return the lexicographically smallest such substring (or empty if none). This can be solved by examining windows spanning k consecutive '1's and choosing the minimum-length window with lexicographic tie-breaking.


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.