Leetcode Daily Question: post #2774 — TG.ME

leetcode.cn 2026-08-26
🟡2904.shortest-and-lexicographically-smallest-beautiful-string

🏷️ Tags
#string #sliding_window
Telegraph
shortest-and-lexicographically-smallest-beautiful-string
给你一个二进制字符串 s 和一个正整数 k 。 如果 s 的某个子字符串中 1 的个数恰好等于 k ,则称这个子字符串是一个 美丽子字符串 。 令 len 等于 最短 美丽子字符串的长度。 返回长度等于 len 且字典序 最小 的美丽子字符串。如果 s 中不含美丽子字符串,则返回一个 空 字符串。 对于相同长度的两个字符串 a 和 b ,如果在 a 和 b 出现不同的第一个位置上,a 中该位置上的字符严格大于 b 中的对应字符,则认为字符串 a 字典序 大于 字符串 b 。
August 26, 2026 29